Friday, December 20, 2013

things I learned in a JavaScript training yesterday

  1. === which is the strictly equals operator evaluates BOTH value and type!
  2. I am making closures too complicated here. A closure is just a circumstance wherein a variable declaration is followed by a function and the function makes use of the variable that was defined outside of its scope by way of the the variable living upstream from the function within the same blob of code (another function perhaps) that holds the function. Yes, you may do this without a scope problem and it is called a closure.
  3. bind is the plain Jane JavaScript way to do what you'd do with lang.hitch in Dojo, namely pass the scope of "this" as is into another setting where it would otherwise be different.
  4. strict mode is going to be cross with you if you declare a variable without using the var keyword. You may technically do this in JavaScript and a variable will end up in global scope. Strict mode will block this bad practice.
  5. The distinction between callback and promises is that promises are a better way to do callbacks. Instead of handing in a function as an object/variable to an asynchronous thing to fire off when the asynchronous item finishes its chore, one may use .when() implementations and moreover chain .when() implementations.

No comments:

Post a Comment