手写 Function.prototype.call:
Function.prototype.myCall = function (context, ...args) {
context = context || window;
const fn = Symbol('fn');
context[fn] = this;
const result = context[fn](...args);
delete context[fn];
return result;
}
手写 Function.prototype.call:
Function.prototype.myCall = function (context, ...args) {
context = context || window;
const fn = Symbol('fn');
context[fn] = this;
const result = context[fn](...args);
delete context[fn];
return result;
}