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

hoisting


    (function(){
        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