Function.prototype.call = function(context){
var ctx = context || window;
ctx.func = this;
var args = Array.from(arguments).slice(1);
var results = !!args.length ? ctx.func(...args) : ctx.func();
delete ctx.fun;
return results;
}
Function.prototype.apply = function(context){
var ctx = context || window;
ctx.func = this;
var args = Array.from(arguments).slice(1, 2);
var results = !!args.length ? ctx.func(...args) : ctx.func();
delete ctx.fun;
return results;
}
Function.prototype.bind = function(context){
var ctx = JSON.parse(JSON.stringify(context)) || window;
ctx.func = this;
var args = Array.from(arguments).slice(1, 2);
return function() {
return !!args.length ? ctx.func(...args) : ctx.func()
}
}
console