【发布时间】:2019-03-13 17:53:01
【问题描述】:
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 中它返回 5 而不是 TypeError: undefined is not a function 的预期结果,正如 2014 年的 SO: Array.prototype.find() is undefined 所述。
所以...我是否遗漏了什么,IE11 真的不能与 Array.prototype.find 一起正常工作,或者是不久前对 IE11 进行的最后更新(但晚于 2014 年讨论的上述 SO 问题) 变成支持这种方法了吗?
当说 IE11 不支持 Array.prototype.find 时,https://caniuse.com/#search=find 是否正确?有证据吗?
谢谢。
【问题讨论】:
-
您是在 SO 的上下文中运行它吗?好吧,SO 可能已经使用 polyfill 定义了该方法……在 "empty" 页面上再试一次!
-
不,它来自另一个网站。 SO 背景只是另一个(但不是第三个)窗口。这可能是查找该方法是否在我进行测试的网站上定义的原因。我会让你知道。是的 - 我在 SO 中的运行代码 sn-p 中看到它会导致 IE11 出现错误。
标签: javascript cross-browser internet-explorer-11