Jump to content

Scope modifiers: Difference between revisions

m (syntax highlighting fixup automation)
Line 703:
 
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|jq}}==
 
jq uses lexical scoping.
 
Variables defined on the command-line have global scope
but are hidden by the rules of lexical scoping.
 
Local scope is introduced by function declarations (including declarations of inner functions)
and by variable assignments, i.e. by `def` and `as` statements.
 
Example:
<pre>
jq -nc --arg x a '
def a($x):
def b($x): 1 as $x | $x;
$x, b(10)];
 
[$x, a(0)]'
</pre>
{{Output}}
<pre>
["a",[0,1]]
</pre>
 
=={{header|Julia}}==
2,460

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.