Sugar augments the existing JavaScript environment with helper methods on existing objects. From fixing broken support of standard methods, widening acceptable arguments, multi-lingual and improved regex support on strings, nice supplementary string methods like words()
, and shortcut methods to Math object methods. Additional helpers for Dates, Objects, Functions and Regex. An library for a consistentising JavaScript across different imlementations.
Ayman Hourieh covers some interesting manipulation of Arrays that accommodates typical data structures. He also covers how to bind methods to objects, sorting with custom functions. He shows a custom AssertException, and covers using Firebug for debugging. He covers some JavaScript quirks: static local variables, null, undefined and delete.
Angus Croll takes the reader step-by-step through some basic JavaScript code explaining what 'this' is in each step and why. He explains how 'this' depends on the execution context, and how it is manipulated by how JavaScript functions are called (or applied or bound with bind), and how Constructors create a new context.
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
Tim Caswell describes the JavaScript variable 'this', which is about current scope and current context. The only way to create scope in JavaScript is through function definitions, and in most cases the context is the receiver of the message (the object before the dot in the method call). He also talks about approaches to controlling what this references with call, apply and bind.
Cory Hudson sees callbacks as benefiting from currying JavaScript functions, and defines currying as turning a function with two arguments into a function with one argument that returns a function of one argument. He starts off with two functions and shows how to combine them into one curried function, and also builds a generic version. He shows a good usage of a curried function in an array map()
function, which is similar to Prototype's bind()
.
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.