02 JavaScriptBasics
02 JavaScriptBasics
Variables
Scopes
No code block scopes (e.g. inside if, for, while) window and global scope
Frames, multiple global scopes and security concerns
Scope Chains
Closures
function A() { var a = 'A scope'; function B() { var b = 'B scope'; alert(a); } B(); alert(b); } var uniqueID = (function() { var id = 0; return function() { return id++; }; })();
Operators have precedence and associativity (unary, assign, ternary are right-to-left)
Arithmetic operators: +, -, *, /, %, ++, --
Other operators: ?:
Statements
Statements we already know: if, else, do/while, switch, for, for/in, break, continue with statement Empty statement ; switch also works with string values