Scope modifiers: Difference between revisions
Content added Content deleted
m ({{omit from|Locomotive Basic}}) |
(→JavaScript: new example) |
||
Line 269: | Line 269: | ||
//can use x and y here, but NOT z |
//can use x and y here, but NOT z |
||
}</lang> |
}</lang> |
||
=={{header|JavaScript}}== |
|||
There are not precisely any scope ''modifiers'' in JavaScript. |
|||
The <code>var</code> variable declaration makes a variable local to a function, and function parameters are also local. Any variable not so declared is global, except in ES5 strict mode where an undeclared variable is an error. |
|||
A named function definition (<code>function foo() { ... }</code>) is “hoisted” to the top of the enclosing function; it is therefore possible to call a function before its definition would seem to be executed. |
|||
=={{header|Logo}}== |
=={{header|Logo}}== |