You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
227 B
13 lines
227 B
13 years ago
|
// function-closure
|
||
|
|
||
|
var a = 40; // a global var
|
||
|
|
||
|
function closure() {
|
||
|
var a = 39; // a local var;
|
||
|
return function() { return a; };
|
||
|
}
|
||
|
|
||
|
var b = closure(); // the local var a is now hidden
|
||
|
|
||
|
result = b()+3 == 42 && a+2 == 42;
|