题解 | #修改 this 指向#

修改 this 指向

https://www.nowcoder.com/practice/a616b3de81b948fda9a92db7e86bd171

function bindThis(f, oTarget) {

//apply传入的参数是数组形式传入,立即执行需要写function()

return function(){

return f.apply(oTarget,arguments)

}

}

function bindThis(f,oTarget){

//和call一样,但是返回的是函数,需要调用才执行

return f.bind(oTarget)

}

function bindThis(f,oTarget){

//后面的参数一个个传入,立即执行需要写function()

return function(){

return f.call(oTarget,...arguments)

}

}

全部评论

相关推荐

叁六玖:你看,最后不是让你加油,就是鼓励你,还祝福你求职顺利。
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

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