Quirks
Hoisting
Even though JS code is interpreted from top, function
s and var
declarations are put on top of the file even if it is written in somewhere in the middle.
Note that only declarations are hoisted, not initializations.
console.log(x);
var x = 10;
Hoisted code looks like:
var x = undefined;
console.log(x);
x = 10;
So the logged output will be undefined
not 10.
CS/Languages/JS/Type System#Type Systems Implicit Casting Implicit Type Coercion