关键词: this, 'use strict'
"use strict";
let fun = function () {
console.log(this);
return this;
}
console.log(this); // window
console.log(fun() === undefined); // undefined true
console.log(fun.call(2) === 2); // 2 true
console.log(fun.apply(null) === null); // null true
console.log(fun.call(undefined) === undefined); // undefined true
console.log(fun.bind(true)() === true); // true true
结果如下图:
参考: 严格模式-MDN