美文网首页
Function.prototype.bind实现

Function.prototype.bind实现

作者: 一只重拾梦想的小水 | 来源:发表于2019-01-20 20:07 被阅读0次

    Function.prototype.bind=function(that, rest){

    const outterThis = this;

    return function(){

    const innerThis = outterThis;

    Array.prototype.splice.call(arguments, 0, rest.length, ...rest)

    innerThis.apply(that, arguments)

    }

    }

    Function.prototype.bind=function(that, rest){

    return (...argu)=>{

    argu.splice(0, rest.length, ...rest)

    this.apply(that, argu)

    }

    }

    相关文章

      网友评论

          本文标题:Function.prototype.bind实现

          本文链接:https://www.haomeiwen.com/subject/rzlfjqtx.html