I’ve been testing the following code, but Firefox16 and Chrome22 gives me different outcomes.
console.log(this===window); //false in Firefox and true in Chrome
console.log(this.window===window); //true in both Firefox and Chrome
(function(){
console.log(this===window); //false in Firefox and true in Chrome
console.log(this.window===window); //true in both Firefox and Chrome
})();
As far as I can remember, Chrome’s answer is right: Unless called with new, this is always same as the global object window, which leads to a pattern called scope safe constructors.
This is actually answered in the Firefox’s Web Console documentation itself: