【发布时间】:2013-02-14 15:16:13
【问题描述】:
在 Chrome Dev Console 中测试了一些 js 代码,我有点困惑。
我知道在 严格模式 中,当引用 this 关键字时不是对象方法的函数应该接收 undefined 而不是全局对象.
function test(){
"use strict";
return this===undefined;}
test();
输出 false。
"use strict";
function test(){
return this===undefined;}
test();
仍然错误。
(function test(){
"use strict";
return this===undefined;}());
输出 true。
只是想澄清一下。 ʕ •ᴥ•ʔ 我是 js 新手。
【问题讨论】:
-
@hexblot 这并没有回答这个问题......
标签: javascript ecmascript-5 strict