`this` example #2

Addressing the misinformation in http://blogs.sitepoint.com/javascript-this-gotchas/

by John Schulz

HTML

<script src="http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js"></script>
<!-- keeping the Firebug Lite settings here so as not to confuse things -->
<script>
    firebug.env.height = 200;
    firebug.env.debug = true;
    firebug.env.detectFirebug = true;
</script>

JavaScript

window.WhoAmI = "I'm the window object";
var Module = new function() {

    this.WhoAmI = "I'm the Module object";

    function Test() {
        this.WhoAmI = "I'm still the Module object";
    }
    return {
        WhoAmI: this.WhoAmI,
        Test: Test
    };
}();

console.log(Module.WhoAmI); // I'm the Module object
console.log(window.WhoAmI); // I'm the Module object
Module.Test();
console.log(Module.WhoAmI); // I'm still the Module object