第一个参数是绑定的this,默认为window,第二个参数是数组或类数组
参考答案:
1Function.prototype.apply = function(context = window, args) { 2 if (typeof this !== 'function') { 3 throw new TypeError('Type Error'); 4 } 5 const fn = Symbol('fn'); 6 context[fn] = this; 7 8 const res = context[fn](...args); 9 delete context[fn]; 10 return res; 11} 12
最近更新时间:2021-07-07