题解 | #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 四川

相关推荐

01-11 08:47
门头沟学院 Java
choumoduji...:读研的目的就是为了以最快的速度和最低的要求完成“学校”规定的毕业标准,而不是所谓课题组的要求
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
3
收藏
分享

创作者周榜

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