function funcA(arg1) {
var enclosedVariable= arg1;
return {
funcB: function () {
alert(enclosedVariable);
}
};
}
Here is a quick and dirty example. ^^
funcA
takes an argument and saves it then returns an object containing a single function. It has been "enclosed" and now funcB
has access to this.
Technically you don't even have to save it... arg1
is available to funcB
as well.