Array.prototype.find() 对比 IE11

Array.prototype.find() vs IE11

https://caniuse.com/#search=find 指出 IE11 不支持 find() 方法。

同时我正在IE11中测试这个find()方法,我没有发现任何错误行为的痕迹。

我也在 IE11 中测试过代码

function isPrime(element, index, array) {
  var start = 2;
  while (start <= Math.sqrt(element)) {
    if (element % start++ < 1) return false;
  }
  return (element > 1);
}

console.log([4, 5, 8, 12].find(isPrime)); // 5

来自 SO: Array.prototype.find() is undefined

是的,在 IE11 中 returns 预期结果 5 而不是 TypeError: undefined 不是一个函数,如 SO: Array.prototype.find() is undefined 在 2014 年所述。

所以...我是不是遗漏了什么,IE11 真的不能与 Array.prototype.find 一起正常工作,或者 IE11 的最后更新是在一段时间之前进行的(但晚于上面讨论的 SO 问题在 2014 年)开始支持这种方法?

当说 IE11 不支持 Array.prototype.find 时,https://caniuse.com/#search=find 是否正确?有证据吗?

谢谢。

UPD:这是我的 IE11 的屏幕:

您所读的一切都是正确的。您的测试存在缺陷。也许您包含了一个在 IE11 中添加该方法的 Polyfill。

您可以尝试以下步骤来验证:

  1. 在 IE 中打开一个空白选项卡。
  2. 在开发工具中打开控制台。
  3. 输入以下代码:[1,2,3].find(function(n) { !!n; })
    • 如果上面的代码抛出错误(它应该),你正在使用一个 polyfill。因此您的代码不会中断。
    • 如果有效,唯一的解释是不知何故,一些更新添加了它的定义。但这不太可能,因为 MS 已停止支持它。

这是我得到的: