Non-local variable: Difference between revisions

Content deleted Content added
mNo edit summary
Tags: Mobile edit Mobile app edit iOS app edit
m clean up, typo(s) fixed: Javascript → JavaScript
Line 18:
</syntaxhighlight>
 
In JavascriptJavaScript, 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() {
Line 46:
==Notes==
{{reflist}}
 
== References ==
* Aho, Lam, Sethi, and Ullman. "7.3 Access to Nonlocal Data on the Stack". ''[[Compilers: Principles, Techniques, & Tools]]''. Second edition.