Function.prototype.my_call = function(context){
let ctx = context || window;
ctx.fn = this;
let args = Array.from(arguments).slice(1);
let res = arguments.length > 1 ? ctx.fn(...args) : ctx.fn();
delete ctx.fn;
return res;
}
Function.prototype.my_apply = function(context){
let ctx = context || window;
ctx.fn = this;
let res = arguments.length > 1 ? ctx.fn(...arguments[1]) : ctx.fn();
delete ctx.fn;
return res;
}
Function.prototype.my_bind = function(context){
let ctx = context || window
ctx.fn = this
let args = Array.from(arguments).slice(1)
return function(){
let allArgs = args.concat(Array.from(arguments));
return allArgs.length > 0 ? ctx.fn(...allArgs) : ctx.fn()
}
}