自定义apply方法:和call方法类似,接受参数的方式不一样
1、函数调用
2、接受参数
3、改变this指向
Function.prototype.myApply=function(target,params){
target.__proto__.fn=this;
target.fn(...params);
delete target.__proto__.fn;
};
function register(a,b,c,d,e){
console.log(this);
console.log(a,b,c,d,e)
}
const obj = {
user:"我是obj"
}
const arr=[1,2,3,4,5]
register.myApply(obj,arr);