Variables. (JavaScript for Novice)
Set of the problems: Click here to start drill.
Generic variables information
Links to read:Variables names
Links to read:- Variables names on www.codelifter.com
- JavaScript reserved words on msdn.microsoft.com
- Verify variable name online
Declaration and assigning
Links to read:- definition vs. initialization on stackoverflow.com
- mozilla.org: declaration and assigning
- difference between declaration, definition and initialization
Variables types and typeof operator
Links to read:- Loosely typed language
- Primitive Types and Reference Types
- developer.mozilla.org: typeof operator
- javascriptkit.com: typeof operator
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:- 8 minute video.
- Brief explanations on stackoverflow.com
- The pretty complex and comprehencive tutorial on toddmotto.com
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:- Very compact explanation on developer.mozilla.org
- 1 minute video fragment.
- The pretty comprehencive tutorial