Function.prototype.apply2 = function (context, ...args) {
context = context || window
context.fn = this;
const result = context.fn(args)
delete context.fn
return result
}
let obj = {
value: 2,
test() {console.log(this.value)}
}
function test () {
console.log(this.value)
}
test.apply2(obj);