-
introduction
- JavaScript coding patterns are the main topic of the book
- console.dir()
-
essentials
-
minimize globals
- namespacing pattern
- self-executing immediate functions
- always use var to declare variables
-
var a = b = 0
-
a is local but b becomes global
- right-to-left evaluation
-
use a single var statement at the top of your functions
- all uninitialized and declared variables are initialized with the value undefined
- hoisting
-
for loops
- A problem with this pattern is that the length of the array is accessed on every loop iteration
-
for-in loops
-
hasOwnProperty()
- var hasOwn = Object.prototype.hasOwnProperty
- hasOwn.call(m,p)
- switch Pattern