Open azcvcza opened 5 years ago
let outerThis, tfeThis, afeThis;
let obj = {
outer() {
outerThis = this;
traditionalFE = function() {tfeThis = this};
traditionalFE();
arrowFE = () => afeThis = this;
arrowFE();
}
}
obj.outer();
简单的说,outerThis的形式,类似于, var that = this; 因此绑定的是outer()这块的空间。 而traditionalFE绑定的是window afeThis则也是绑的outer();
outerThis; // obj tfeThis; // global afeThis; // obj outerThis === afeThis; // true
GogOgo