手写apply
/**
* Function.apply(this: Function, thisArg: any, argArray?: any): any
* @param {*} context
*/
Function.prototype._apply = function(context){
if(typeof this !== 'function'){
throw 'Error'
}
context = context || window
const args = [].concat(arguments[1] || [])
context.fn = this
const result = context.fn(...args)
delete context.fn
return result
}
const fn = function(){console.log(this);return {test:1,...this}}
fn._apply({_apply:1})