Glossary: Closure
A "closure" is a function that has data intrinsically bound to it, for instance by virtue of where it's defined. This is a closure:
var a; a = 5; function myFunction() { // ... }
"myFunction" is a closure: The 'a' variable is bound to it, because 'a' is in scope where 'myFunction' is defined. There's also a closure here:
var a; a = ['a', 'b', 'c']; a.each(function(v) { alert(v); });
The anonymous function used with the each method is a closure.
More on closures:
page revision: 0, last edited: 08 Oct 2008 09:48