Variable statement (Definition)

A variable statement uses the var keyword to preface a list of variable declarations.

Availability:

ECMAScript edition - 2

A variable statement uses the var keyword to preface a list of variable declarations. The statement is terminated with a semicolon.

You can declare the variables one at a time or several at once with the same var statement.

When the variables are declared, an initial value can be assigned to them at the outset.

Variables can be declared inside a function body. When they are declared there, they become local only to that function. When the function exits, the execution context is popped off the scope chain and the variables are discarded.

Variables can also be declared and assigned within a for loop header block.

See also:= (Assign), Assignment expression, delete, Statement, var, Variable Declaration

Cross-references:

ECMA 262 edition 2 - section - 10.1.3

ECMA 262 edition 2 - section - 12.2

ECMA 262 edition 3 - section - 10.1.3

ECMA 262 edition 3 - section - 12.2