What is a good javascript (book or site) that is not just focused on syntax but does a good job explaining how javascript works behind the scenes? Thanks!
Closures are important because they control what is and isn't in scope in a particular function, along with which variables are shared between sibling functions in the same containing scope.
A closure is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment). In other words, a closure gives you access to an outer function's scope from an inner function.
JavaScript is officially maintained by Mozilla so only documentation by Mozilla is official. The only engines that support JavaScript are currently made by Mozilla and every other engine implements ECMAScript.
This is called a JavaScript closure. It makes it possible for a function to have "private" variables. The counter is protected by the scope of the anonymous function, and can only be changed using the add function. A closure is a function having access to the parent scope, even after the parent function has closed.
The JavaScript resources at the Mozilla Developer Center are pretty nice. They have a guide to JavaScript as well as a a reference.
The guide isn't really that great, but the reference is awesome. If I'm looking for something, I just use google with 'mdc' (or 'mdc javascript' in ambiguous cases) + keyword as search terms.
It might also be a good idea to read the 3 1/2 page long sections 4.2 and 4.3 of ECMA-262. Also, consider reading chapter 10.
The rhino book is an excellent book to have on your desk.
If you don't want a book that starts with explaining JavaScript syntax, then:
Watch the video lectures of Douglas Crockford in YUI Theater:
Read Pro JavaScript Techniques by John Resig (the author of jQuery library).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With