Remy Sharp dissects a piece of jQuery code pointing out the red flags. Each flag is taken in turn, explained and shown how to correct. Takes into account context and the flexibility of jQuery
Jonathan Snook demonstrates when JavaScript passes by reference or passes by value. Essentially, primitive types are passed by value, objects are passed by reference. Passing functions however, makes things look like a pass by value if the this
keyword is being used in the code. Snook offers workarounds to this by passing objects so that the context is correct, or using the call()
function to ensure the context is correct.
Christian Heilmann compares the Object Literal to Douglas Crockford's Module pattern and finds that the Module pattern fixes a major problem of the object literal - the difficult choice of using this or fully qualified references to functions in the same block. Christian also covers the improvements in the Module Pattern, like the decluttering of the return block, which makes the resulting a little easier to work with.
Dustin Diaz discusses the Object Literal form of JavaScript, pointing out benefits such as better organisation of code in a namespace / wrapper.
Douglas Crockford discusses how to create private members and methods, and using privileged methods to bridge the gap between public and private. It also contains the simplest and most understandable definition of closures I've ever seen.
An explanation of scope in terms of an execution context and scope chain. Also describes how we can alter the this reference using apply and call.
LowPro is a scripting extension to Prototype written by Dan Webb to make unobtrusive DOM Scripting much easier. Included are an onReady event, adding behaviour using CSS selectors, fixing the this reference to always refer to the element within events, and a mechanism for triggering events.
Dean Edwards presents his improvement to Scott Andrews' famous addEvent()
functions. Solving the cross-browser this
reference differences, and passing event
objects correctly.