created by Brian LeRoux & Andrew Lunny. sparodically uncurated by David Trejo.

2010 02 15 hoisting

        alert(window);  // "undefined"
        var window = window;

Because of “hoisting”, all variable declarations will be executed immediately at the top of a function scope. However, the variable initializations are not hoisted. So, local variable “window” is declared but uninitialized/”undefined”. wt-fun!

Fork me on GitHub