Variable instantiation (Definition)

Variables are local to one execution context.


ECMAScript edition - 2

Every execution context has its own variable object associated with it. Variables declared in the source text are added as properties to the variable object.

This mechanism is a way of making sure that variables that are local to one execution context do not affect the values of variables in another.

In the case of global and eval() code, any functions that are declared in the script source text are also added as properties of the variable object. JavaScript 1.3 and ECMAScript edition 3 introduces nested functions which means they will be added too.

For function, anonymous, and implementation-supplied code contexts, any passed in arguments (parameters) are also added as properties of the variable object.

Which particular variable object is used, and what attributes its properties take on depends on the type of code.

See also:Execution context, Formal Parameter List, function( ... ) ..., Script Source Text, Variable Declaration


ECMA 262 edition 2 - section - 10.1.3

ECMA 262 edition 3 - section - 10.1.3