bind 的实现
Function.prototype.myBind = function (that, ...args) {
let fn = this
return function () {
return fn.apply(that, [...args, ...arguments])
}
}
call 的实现
Function.prototype.myCall = function (that, ...args) {
that.fn = this
let res = that.fn(...args)
delete that.fn
return res
}
apply 的实现
Function.prototype.myApply = function (that, args) {
that.fn = this
let res = that.fn(...args)
delete that.fn
return res
}