Variables. (JavaScript for Novice)

Set of the problems: Click here to start drill.

Generic variables information

Links to read:

Variables names

Links to read:

Declaration and assigning

Links to read:

Variables types and typeof operator

Links to read:

Javascript Variable Scope.

There is typically one global scope, and each function defined has its own (nested) local scope. Any function defined within another function has a local scope which is linked to the outer function.

Statement aVar=10; (without var) creates variable in a global scope (of course if variable was not defined before).

Block scope (grouped statements with curly braces { ... } ) created by if, for, while, switch and other statements does not define a new scope. Only function has it's own scope.

Links to read:

Javascript hoisting.

Variable and funtion declarations are processed before any code is executed.

For variable gets hoisted declaration only. Value would be "undefined".

Function gets hoisted completely (name and implementation).

Links to read:

Further reading: