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

相关推荐

安静的鲸鱼offer...:神仙级别hr,可遇不可求,甚至他可能也是突然有感而发。只能说遇上是件幸事。
秋招开始捡漏了吗
点赞 评论 收藏
分享
12-24 20:44
武汉大学 Java
点赞 评论 收藏
分享
评论
3
收藏
分享

创作者周榜

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