题解 | #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)
}
}
使用隐式绑定
