Fundamental JavaScript:  The Language Presented by Brian Dukes
Where are we going? Feature Overview Syntax Objects Functions Inheritance Miscellaneous
Feature Overview 1st Class Functions Loose Typing Dynamic Objects Prototypal Inheritance Global Variables
Where are we? Feature Overview Syntax Objects Functions Inheritance Miscellaneous
Syntax: Primitive Types Number 64-bit floating, " double " String Surrounded by single or double quotes Boolean true  or  false Objects Key/value pairs Arrays Indexed collection Functions Callable code
Syntax: Truthy & Falsy Values Falsy values: false null undefined '' 0 NaN Truthy values: Everything else true ,  'false' ,  {}
Syntax: Statements & Operators var  if switch while for for in do while try throw return break   with ternary ( ? : ) typeof || && ==  &  === !=  &  !== + !
Where are we? Feature Overview Syntax Objects Functions Inheritance Miscellaneous
Objects: Literals JSON (plus functions) Name/value pairs Name is any string Quotes are optional for legal name Value can be any JavaScript value: Other objects Functions Arrays
Objects: Setting & Getting var flight = {      airline: "Oceanic",      number:  815 }; alert(flight.airline); alert(flight.equipment); // undefined  flight.equipment.status // throw "TypeError"  flight.equipment = {      model: 'Boeing 777'  }; flight['flight-status'] = 'overdue'; alert(flight["flight-status"]);
Where are we? Feature Overview Syntax Objects Functions Inheritance Miscellaneous
Functions: Definition Functions are objects Functions have a prototype Functions can have properties Functions can have methods Functions can be passed as arguments to functions Functions can be returned from functions Functions can be invoked
Functions: Closure Functions have access to outer variables this  &  arguments  are different for each function   var i; for (i = 0; i < 10; i++) {      setTimeout(function () {          console.log(i*i);      }, i); }  
Functions: Scope Does  not  have block scope Unlike every other language with C style syntax Function scope function outer () {      for (var i = 0; i < 10; i++) {          var double = i+i;          $link.click(function () {               alert(double)           });      } } 
Functions: Callbacks Functions can be passed to other functions    makeAjaxCall(function (result) {      alert(result);  }); 
Functions: Module Pattern Call an anonymous function after declaring it ( IIFE ) Keeps inner values from being accessible outside of the function   (function () {      var x = 1; }());
Where are we? Feature Overview Syntax Objects Functions Inheritance Miscellaneous
Inheritance: Pseudoclassical new  operator Function names are capitalized, by convention Lots of downfalls
Inheritance: Prototype All objects has a prototype property When retrieving properties, any property not on the object is retrieved from its prototype If the property isn't on the prototype,  its  prototype is checked, etc.
Where are we? Feature Overview Syntax Objects Functions Inheritance Miscellaneous
Miscellaneous: Arrays Literal notation:  [true, 1, &quot;string&quot;, {}] length  property Not bounded Use  push  method to add to the end Is a weird object, not a &quot;real&quot; array
Miscellaneous: Regular Expressions Pattern Matching Literal notation:  /pattern/options
Resources JavaScript Weekly -  http://javascriptweekly.com/ JSLint -  http://www.jslint.com/ JSLint.VS2010 -  http://bit.ly/JSLint-VS2010 jsFiddle -  http://jsfiddle.net/ MDC -  https://developer.mozilla.org This -  http://www.slideshare.net/EngageSoftware/

JavaScript: The Language

  • 1.
    Fundamental JavaScript: TheLanguage Presented by Brian Dukes
  • 2.
    Where are wegoing? Feature Overview Syntax Objects Functions Inheritance Miscellaneous
  • 3.
    Feature Overview 1stClass Functions Loose Typing Dynamic Objects Prototypal Inheritance Global Variables
  • 4.
    Where are we?Feature Overview Syntax Objects Functions Inheritance Miscellaneous
  • 5.
    Syntax: Primitive TypesNumber 64-bit floating, &quot; double &quot; String Surrounded by single or double quotes Boolean true or false Objects Key/value pairs Arrays Indexed collection Functions Callable code
  • 6.
    Syntax: Truthy &Falsy Values Falsy values: false null undefined '' 0 NaN Truthy values: Everything else true , 'false' , {}
  • 7.
    Syntax: Statements &Operators var if switch while for for in do while try throw return break with ternary ( ? : ) typeof || && == & === != & !== + !
  • 8.
    Where are we?Feature Overview Syntax Objects Functions Inheritance Miscellaneous
  • 9.
    Objects: Literals JSON(plus functions) Name/value pairs Name is any string Quotes are optional for legal name Value can be any JavaScript value: Other objects Functions Arrays
  • 10.
    Objects: Setting &Getting var flight = {     airline: &quot;Oceanic&quot;,     number:  815 }; alert(flight.airline); alert(flight.equipment); // undefined flight.equipment.status // throw &quot;TypeError&quot; flight.equipment = {     model: 'Boeing 777' }; flight['flight-status'] = 'overdue'; alert(flight[&quot;flight-status&quot;]);
  • 11.
    Where are we?Feature Overview Syntax Objects Functions Inheritance Miscellaneous
  • 12.
    Functions: Definition Functionsare objects Functions have a prototype Functions can have properties Functions can have methods Functions can be passed as arguments to functions Functions can be returned from functions Functions can be invoked
  • 13.
    Functions: Closure Functionshave access to outer variables this & arguments are different for each function   var i; for (i = 0; i < 10; i++) {     setTimeout(function () {         console.log(i*i);     }, i); }  
  • 14.
    Functions: Scope Does not have block scope Unlike every other language with C style syntax Function scope function outer () {     for (var i = 0; i < 10; i++) {         var double = i+i;         $link.click(function () {              alert(double)          });     } } 
  • 15.
    Functions: Callbacks Functionscan be passed to other functions   makeAjaxCall(function (result) {     alert(result); }); 
  • 16.
    Functions: Module PatternCall an anonymous function after declaring it ( IIFE ) Keeps inner values from being accessible outside of the function   (function () {      var x = 1; }());
  • 17.
    Where are we?Feature Overview Syntax Objects Functions Inheritance Miscellaneous
  • 18.
    Inheritance: Pseudoclassical new operator Function names are capitalized, by convention Lots of downfalls
  • 19.
    Inheritance: Prototype Allobjects has a prototype property When retrieving properties, any property not on the object is retrieved from its prototype If the property isn't on the prototype, its prototype is checked, etc.
  • 20.
    Where are we?Feature Overview Syntax Objects Functions Inheritance Miscellaneous
  • 21.
    Miscellaneous: Arrays Literalnotation: [true, 1, &quot;string&quot;, {}] length property Not bounded Use push method to add to the end Is a weird object, not a &quot;real&quot; array
  • 22.
    Miscellaneous: Regular ExpressionsPattern Matching Literal notation: /pattern/options
  • 23.
    Resources JavaScript Weekly- http://javascriptweekly.com/ JSLint - http://www.jslint.com/ JSLint.VS2010 - http://bit.ly/JSLint-VS2010 jsFiddle - http://jsfiddle.net/ MDC -  https://developer.mozilla.org This - http://www.slideshare.net/EngageSoftware/

Editor's Notes

  • #8 for in enumerates all properties in prototype chain   + is for addition and concatenation (make sure both are numbers if you want addition) + and ! are also for coercion
  • #14 Image Carousel example
  • #17 vv