热门

最新

红包

立Flag

投票

同城

我的

发布
cc18868876837
码飞_CC
5 年前
truecc18868876837

apply的实现:

Function.prototype.apply = function(context = window, args) {
if (typeof this !== 'function') {
throw new TypeError('Type Error');
}
const fn = Symbol('fn');
context[fn] = this;

const res = context[fn](...args);
delete context[fn];
return res;
}

CSDN App 扫码分享
分享
评论
2
打赏
  • 复制链接
  • 举报
下一条:
为什么我的发的东西被删除了?
立即登录