like javascript does, local function inside functions captures all local variables and it stores in a "environment" as extern scope,
Example,
function f1(){
var i=0;
return function(){
i++;
Console::outln(i)
}
}
var f=f1();
f(); // <-- it prints 1
f();// <-- it prints 2
So if the variable is not found as local, then it tries to find it in its environment.
like javascript does, local function inside functions captures all local variables and it stores in a "environment" as extern scope,
Example,
So if the variable is not found as local, then it tries to find it in its environment.