题解 | #_call函数#

_call函数

http://www.nowcoder.com/practice/22df1ed71b204a46b00587fdb780b3ab

Function.prototype._call=function(){
    const self=this//self为调用_call的函数

    const args=[...arguments]//参数

    const thisValue=args.shift()//取第一个参数,即为this

    thisValue.fn=self//在this上先挂上一个函数

    const res=thisValue.fn(...args)//调用函数

    delete thisValue.fn//删掉

    return res
  
}
全部评论

相关推荐

牛客66512506...:那个百度acg是不是个小哥啊,老是问些底层问题狠狠为难,然后kpi
哪些公司在招寒假实习?
点赞 评论 收藏
分享
评论
3
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务