第一个参数是绑定的this,默认为window,第二个参数是数组或类数组
参考答案:
1Function.prototype.apply = function(context, args) { 2 context = (context === undefined || context === null) ? globalThis : Object(context); 3 if (typeof this !== 'function') { 4 throw new TypeError('Type Error'); 5 } 6 const fn = Symbol('fn'); 7 context[fn] = this; 8 9 const res = context[fn](...args); 10 delete context[fn]; 11 return res; 12} 13
最近更新时间:2025-08-26
题库维护不易,您的支持就是我们最大的动力!