我在Chrome Dev Console中测试了一些js代码,感到有点困惑。
我知道在严格模式下,不是对象方法的函数被引用时,应该接收undefined而不是全局对象。
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;}());
输出true。
只是想澄清一下。ʕ •ᴥ•ʔ 我是js的新手。