1. apply方法(注意没有传context或者为undefined或null或string,number类型时的上下文context)
Function.prototype._apply=function(context){
if(context===undefined||context===null){
context=window;
}
if(typeof context==='string'||typeof context==='number'){
context={};
}
context.fn=this;
let args=arguments[1];
let res;
if(args){
res=context.fn(...args)
}else{
res=context.fn()
}
delete context.fn;
return res;
};
2. call(同样注意传进去的上下文即可,然后参数是从第二个开始)
Function.prototype._call=function(context){
if(context===undefined||context===null){
context=window;
}
if(typeof context==='string'||typeof context==='number'){
context={}
}
context.fn=this;
let args&