Function.prototype.myapply =function(context){ if(typeof this !== "function"){ throw new Error("not a func"); } context.fn = this; let res; if(arguments[1]){ let args = Array.from(arguments).slice(1); res = context.fn(...args); } else{ res = context.fn(); } delete context.fn; } function me(){ console.log(this,arguments); } let o1={a:1,name:'o1'}; let o2 = {a:2,name:'o2'}; me.myapply(o2,[1,2,3,4]);