普通模式
普通模式 this
默认指向了Window
function foo() {
console.log(this);
}
foo(); // Window
严格模式
如果开启严格模式use strict
,this
指向的是 undefined
function foo() {
"use strict";
console.log(this);
}
foo(); // undefined
微信扫一扫
普通模式 this
默认指向了Window
function foo() {
console.log(this);
}
foo(); // Window
如果开启严格模式use strict
,this
指向的是 undefined
function foo() {
"use strict";
console.log(this);
}
foo(); // undefined
相关推荐