Javascript IE 查找索引错误
Javascript IE findindex error
我的以下代码在几乎所有浏览器中都运行良好...除了 Firefox 和 IE...
handles.forEach(function (handle) {
let clIndex = collections.findIndex(function (col) {
return col.handle == handle;
});
if (clIndex != -1) {
sorted.push(collections[clIndex]);
};
requests--;
});
错误是:
Object doesn't support property or method 'findIndex'
我找到了这个但是没有看到实现它的方法:
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex
如果您尝试在非数组类型的对象上使用 .findIndex()
,则此函数将不起作用。也就是说,collections
一定是一个Array。检查是否属实。
我的以下代码在几乎所有浏览器中都运行良好...除了 Firefox 和 IE...
handles.forEach(function (handle) {
let clIndex = collections.findIndex(function (col) {
return col.handle == handle;
});
if (clIndex != -1) {
sorted.push(collections[clIndex]);
};
requests--;
});
错误是:
Object doesn't support property or method 'findIndex'
我找到了这个但是没有看到实现它的方法: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex
如果您尝试在非数组类型的对象上使用 .findIndex()
,则此函数将不起作用。也就是说,collections
一定是一个Array。检查是否属实。