题解 | #_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
  
}
全部评论

相关推荐

刘湘_passion:太强了牛肉哥有被激励到
点赞 评论 收藏
分享
被普调的六边形战士很高大:项目经历貌似和专业或者求职方向没大关系?
点赞 评论 收藏
分享
评论
3
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务