Non-local variable: Difference between revisions

Content deleted Content added
Added {{More citations needed}} tag
KZ737 (talk | contribs)
 
Line 19:
</syntaxhighlight>
 
In JavaScript, the locality of a variable is determined by 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. Therefore, x is non-local to <code>inner</code>:
<syntaxhighlight lang="javascript">
function outer() {