You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if(!Function.prototype.bind){Function.prototype.bind=function(oThis){if(typeofthis!=='function'){thrownewTypeError();}varaArgs=[].slice.call(arguments,1),self=this,fNOP=function(){},fBound=function(){returnself.apply(thisinstanceoffNOP
? this
: oThis,aArgs.concat([].slice.call(arguments)));};if(this.prototype){fNOP.prototype=this.prototype;}fBound=newfNOP();returnfBound;};}
模拟实现bind方法
模拟实现一个call与apply方法
思路
call
apply
三者区别
call和apply与 bind 最大的区别是 call apply调用即执行了所对应的方法,bind的返回值是改变指向后的这个函数(未执行)
The text was updated successfully, but these errors were encountered: