contents   index   previous   next



SE.FUNCS_ONLY

A script is executed in two parts. First, any function defined in it are extracted and created. Likewise, any variables defined using the var keyword are initialized as undefined. This happens at the very start of the script. The second part executes any code in the script. For instance, consider this script:

 

function foo()

{

   return 10;

}

 

var a = 10;

 

A normal evaluation creates a function foo in the global object as well as a variable a as the undefined value. Then the code in the script is run, assigning a to be 10. If you specify the SE.FUNCS_ONLY flag, only the first part is executed. In this case, the function foo and the variable a are created, but the the script body is not run, so the assignment to a is not executed.

 

Understanding this behavior also is helpful in understanding a subtle ECMAScript rule, that all variables defined with the var keyword are extracted and initialized before any code is run to be the undefined value. In this script example, ECMAScript treats the script as if you wrote instead:

 

var a;

 

function foo()

{

   return 10;

}

 

a = 10;


SE.EXIT_LEVEL