经典this指向问题
代码如下
function f1() {
this.p = function(){
// 这里 this 跟的是p这个func,谁调用p,就跟谁
console.log(this);
}
return this
}
function f2() {
this.p = ()=> {
// 这里this 跟的是f2
console.log(this);
}
return this
}
f1().p.call({})
f2().p.call({})

浙公网安备 33010602011771号