Upgrade to Pro — share decks privately, control downloads, hide ads and more …

JavaScript for Developers

Jos
September 25, 2013

JavaScript for Developers

An intro to JavaScript for people with knowledge about at least one other programming language.

Jos

September 25, 2013
Tweet

More Decks by Jos

Other Decks in Programming

Transcript

  1. JavaScript for developers [email protected] MIT 6.s198 Objectives: - Main concepts

    - Main differences with other languages - Resources to follow up from the session
  2. Functions: 1st class citizens In JavaScript, functions are objects. This

    means that a function can be stored in a variable, array, or object. Also, a function can be passed to, and returned from, a function. http://javascriptenlightenment.com/ var printFullName = function(fullName) { console.log(fullName); }; printFullName(printFullName);
  3. Callback Pattern In computer programming, a callback is a piece

    of executable code that is passed as an argument to other code, which is expected to call back (execute) the argument at some convenient time. Wikipedia: http://en.wikipedia.org/wiki/Callback_(computer_programming) var printFullName = function(fullName) { console.log(fullName); }; printFullName('Grace Hopper'); var createFullNameAndPrintIt = function(first, last, callback){ var fullName = first + ' ' + last; callback(fullName); //Should really check if callback is a function }; createFullNameAndPrintIt('Grace', 'Hopper', printFullName); createFullNameAndPrintIt('Grace', 'Hopper', function(fullName){ console.log('Commander ' + fullName); });
  4. The this keyword The this keyword in JavaScript has different

    meanings, depending on the context in which it is used. In summary: • In a method context, this refers to the object that contains the method. • In a function context, this refers to the global object. • If this is used in a constructor, the this in the constructor function refers to the object which uses the constructor function. • When the apply or call methods are used, the value of this refers to what was explicitly specified in the apply or call invocation. http://dublintech.blogspot.ie/2011/10/are-you-confused-by-this-javascript.html
  5. Other ideas & QA - Thruthy & Falsey, Equality -

    Patterns (namespace, module): Learning JavaScript Design Patterns - Lexical Scope (do not use with)
  6. Resources MDN JavaScript docs: Mozilla Development Network JavaScript the good

    parts: Douglas Crockford JavaScript Patterns: Stoyan Stefanov Learning JavaScript Design Patterns: Addy Osmani jQuery fundamentals: Rebecca Murphy Talks to help you become a better front-end engineer in 2013: Smashing Magazine Crockford on JavaScript: YUI Blog