Content deleted Content added
{{see also|Man or boy test}} |
Add javascript example |
||
Line 11:
print(x)
return inner
</source>
In Javascript, the locality of a variable is determined by the the closest <code>var</code> statement for this variable. In the following example, <code>x</code> is local to <code>outer</code> as it contains a <code> var x</code> statement, while <code>inner</code> doesn't:
<source lang=javascript>
function outer(){
var x = 1;
function inner(){
x += 1;
console.log(x);
}
return inner;
}
</source>
|