bind方法模擬時的原型鏈詳解。
在講bind方法模擬的時候有這么一個問題。
首先,先關(guān)注下這兩行代碼,fNOP.prototype=this.prototype; fBound.prototype=new fNOP();
但是這里的定義和之前的this instanceOf fNOP的判斷的關(guān)系呢?有點不太好理解。
在講bind方法模擬的時候有這么一個問題。
首先,先關(guān)注下這兩行代碼,fNOP.prototype=this.prototype; fBound.prototype=new fNOP();
但是這里的定義和之前的this instanceOf fNOP的判斷的關(guān)系呢?有點不太好理解。
2016-03-27
舉報
2016-03-27
fNOP.prototype=this.prototype;這里this是foo
new func()時this指向一個空對象,原型是func,
this instanceof fNOP?? this就是fNOP的實例