普通模式
普通模式 this 默认指向了Window
function foo() {
console.log(this);
}
foo(); // Window
严格模式
如果开启严格模式use strict,this 指向的是 undefined
function foo() {
"use strict";
console.log(this);
}
foo(); // undefined
js:浏览器环境下普通模式和严格模式use strict下function函数里的this指向
阅读 51
2023-08-15
普通模式 this 默认指向了Window
function foo() {
console.log(this);
}
foo(); // Window
如果开启严格模式use strict,this 指向的是 undefined
function foo() {
"use strict";
console.log(this);
}
foo(); // undefined
相关推荐
精彩评论(0)