Function.prototype.myBind=function(){
let self=this
let context=[].shift.call(arguments) //
let args=[].slice.call(arguments)
return function(){
self.apply(context,[].concat.call(args,[].slice.call(arguments)));
}
}
let obj={
name:‘zxz‘
}
function test(m,n){
console.log(this.name,m,n)
}
let bind=test.myBind(obj,1,2)
bind(3,4)
原文:https://www.cnblogs.com/sky-android/p/12718158.html