gpt4 book ai didi

javascript - Function.prototype.apply.apply - 为什么调用它两次

转载 作者:行者123 更新时间:2023-11-29 10:35:18 26 4
gpt4 key购买 nike

今天在检查Jasmine 的源代码时here我偶然发现了以下内容:

if (queueableFn.timeout) {
timeoutId = Function.prototype.apply.apply(self.timeout.setTimeout, [j$.getGlobal(), [function() {
var error = new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.');
onException(error);
next();
}, queueableFn.timeout()]]);
}

我感兴趣的是为什么apply在这里被调用了两次prototype.apply.apply

最佳答案

commit that introduced this syntax解释一切:

Older IE fixes Still not green, but getting close. Summary of Older IE discrepancies:

  • Older IE doesn't have apply/call on the timing functions
  • Older IE doesn't allow applying falsy arguments
  • Older IE doesn't allow setting onclick to undefined values
  • Older IE doesn't have text property on dom nodes

关于javascript - Function.prototype.apply.apply - 为什么调用它两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37609515/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com