Chaining Variable Assignments in JavaScript: Words of Caution

Declaring multiple variable expressions on a single line is common practice and also a great shorthand syntax. However, while reviewing several developer’s work recently, I noticed many are not aware this creates implicit global variables. (function() { var foo = bar = baz = ‘local’; console.log(foo); // local console.log(bar); // local console.log(baz); // local }()); […]

Identifier Resolution and Closures in the JavaScript Scope Chain

From my previous post, we now know that every function has an associated execution context that contains a variable object [VO], which is composed of all the variables, functions and parameters defined inside that given local function. The scope chain property of each execution context is simply a collection of the current context’s [VO] + […]

What is the Execution Context & Stack in JavaScript?

In this post I will take an in-depth look at one of the most fundamental parts of JavaScript, the Execution Context. By the end of this post, you should have a clearer understanding about what the interpreter is trying to do, why some functions / variables can be used before they are declared and how […]

Futures and Promises in JavaScript

With JavaScript usage constantly on the increase, asynchronous event-driven applications are becoming more and more popular. However, a common issue many developers face is with result-dependent operations being used in an asynchronous environment, you often end up with something like: doA(function(aResult) { // do some stuff inside b then fire callback doB(aResult, function(bResult) { // […]

Yahoo! Mojito @

I recently gave a talk at the JavaScript Developer’s Conference in Taiwan about Yahoo!’s new MVC JavaScript framework, called Mojito. A common problem developers have today when developing a single product is that they need to support so many different devices such as mobile, desktop, tablet etc. Each of these native devices need the same […]