模拟apply

2025 年 3 月 26 日 星期三(已编辑)
2
这篇文章上次修改于 2025 年 3 月 26 日 星期三,可能部分内容已经不适用,如有疑问可询问作者。

模拟apply

2.模拟apply

Function.prototype.myapply = function(context = window, args){
    if(this == Function.prototype){
        return undefined;
    }
    context = context || window;
    const fn = Symbol();
    context[fn] = this;
    if (Array.isArray(args)) {
        result = context[fn](...args);
    }else {
        result = context[fn]();
    }
    delete context[fn]
    return result
}

使用社交账号登录

  • Loading...
  • Loading...
  • Loading...
  • Loading...
  • Loading...