Function.prototype.call = function (obj, ...args) {
obj = obj || window
obj.fn = this
let res = obj.fn(...args)
delete obj.fn;
return res;
}
Function.prototype.apply = function (obj, args) {
obj = obj || window
obj.fn = this
let res = null
if (!args) {
res = obj.fn();
} else {
res = obj.fn(...args)
}
delete obj.Fn
return res;
}
Function.prototype.bind = function (obj) {
let args = [...arguments].slice(1)
let fn = this;
return function Fn() {
return fn.apply(
this instanceof Fn ? this : obj
args.concat(...arguments)
)
}