function apply(fn,obj,args){ //判断 if(obj === undefined || obj === null){ obj = globalThis } //为obj添加临时方法 obj.temp = fn //执行函数 let result = obj.temp(...args) //删除临时函数 delete obj.temp //返回结果 return result }