let obj={
a:1,
b:2,
c:3,
d:4
}
function fun(){
console.log(this);
console.log(this.a);
console.log(arguments);
}
Function.prototype.myCall=function(){
var obj=Array.prototype.shift.call(arguments)
var fun=Symbol()
obj[fun]=this
obj[fun](...arguments)
delete obj[fun]
}
Function.prototype.myApply=function(){
var obj=Array.prototype.shift.call(arguments)
var fun=Symbol()
obj[fun]=this
obj[fun](arguments)
delete obj[fun]
}
Function.prototype.myBind=function(){
var obj=Array.prototype.shift.call(arguments)
var args=arguments
var that=this
return function(){
that.call(obj,...args,...arguments)
}
}
let fun1=fun.myBind(obj,1,2)
fun1(1,2)
|