Function.prototype._call = function(thisArg,...args) { // 1.获取目标函数 var fn = this // 2.将thisArg转换为对象类型,避免传入的是非对象类型 thisArg = (thisArg !== null && thisArg !== undefined) ? Object(thisArg):window // 3.执行函数 thisArg.fn = fn var res = thisArg.fn(...args) delete thisArg.fn // 4.返回结果 return res }