次のコードをテストしてきましたが、Firefox16 と Chrome22 では結果が異なります。
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
})();
私が覚えている限り、Chrome の答えは正しいです。 で呼び出されない限りnew
、this
はグローバル オブジェクト と常に同じでwindow
あり、スコープ セーフ コンストラクターと呼ばれるパターンにつながります。