题解 | #Function.bind#

Function.bind

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

Function.prototype._bind = function(thisArg, ...otherArgs) {
                thisArg = thisArg === null || thisArg === undefined ? window : Object(thisArg)
                thisArg.fn = this
                return (...newArgs) => {
                    const allArgs = [...otherArgs, ...newArgs]
                    return thisArg.fn(...allArgs)
                }
            }

使用隐式绑定
全部评论
还没执行的时候就已经入侵了 thisArg , 给他新注入一个key 并且这个key还有可能覆盖 thisArg 的值。。。
点赞 回复 分享
发布于 2024-06-16 12:28 四川

相关推荐

饼子吃到撑:学院本是这样的,找工作拼运气,你技术再好人家筛选学历照样沉入海底,海投就行了
点赞 评论 收藏
分享
评论
3
收藏
分享

创作者周榜

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