background preloader


Facebook Twitter


Atom syndication format. Introduction to Functional Programming (1996/7) I Will Knot! Javascript Closures. Introduction Closure A "closure" is an expression (typically a function) that can have free variables together with an environment that binds those variables (that "closes" the expression).

Javascript Closures

Closures are one of the most powerful features of ECMAScript (javascript) but they cannot be property exploited without understanding them. They are, however, relatively easy to create, even accidentally, and their creation has potentially harmful consequences, particularly in some relatively common web browser environments. To avoid accidentally encountering the drawbacks and to take advantage of the benefits they offer it is necessary to understand their mechanism.

This depends heavily on the role of scope chains in identifier resolution and so on the resolution of property names on objects.