在中測試了一些js代碼Chrome開發者控制檯,我有點困惑。JavaScript'嚴格使用';裏面的函數
我知道,在嚴格模式函數時提到不屬於某個對象的方法這關鍵字應該得到不確定,而不是全局對象。
function test(){
"use strict";
return this===undefined;}
test();
輸出false。
"use strict";
function test(){
return this===undefined;}
test();
仍然false。
(function test(){
"use strict";
return this===undefined;}());
輸出真正。
只是想澄清。 'm•ᴥ•ʔ我是js的新手。
請閱讀類似的問題http://stackoverflow.com/questions/1335851/what-does-use-strict-do-in-javascript-and-what-is-the-reasoning-behind-it – hexblot 2013-02-28 12:20:40
@hexblot這並不回答這個問題,雖然...... – Christoph 2013-02-28 12:37:00