Function.prototype.bind1 = function() {
const args = Array.prototype.slice.call(arguments)
const t = args.shift()
const self = this
return function () {
return self.apply(t,args)
}
}
function fn1(a,b) {
console.log('this', this)
console.log(a,b);
return 'this is fn1'
}
const fn2 = fn1.bind1({x:100}, 10, 20, 30)
const res = fn2()
console.log(res)
手写bind
最新推荐文章于 2022-03-10 16:39:20 发布
关键词由CSDN通过智能技术生成