IE中的javascript findIndex问题

IE中的javascript findIndex问题,javascript,internet-explorer,Javascript,Internet Explorer,我刚刚完成了一个小表单,发现我如何使用findIndex与IE不兼容 这是一个问题的例子 var people = [ {name:"Mike", age:"25"}, {name:"Bill", age:"35"}, {name:"Terry", age:"44"} ]; console.log(people.findIndex(x => x.name=="Bill" )); 解决IE问题的最快方法是什么?查找浏览器的索引支持 Chrome 45.0 and abo

我刚刚完成了一个小表单,发现我如何使用findIndex与IE不兼容

这是一个问题的例子

var people = [
  {name:"Mike", age:"25"},
  {name:"Bill", age:"35"},
  {name:"Terry", age:"44"}
];
console.log(people.findIndex(x => x.name=="Bill" ));

解决IE问题的最快方法是什么?

查找浏览器的索引支持

    Chrome 45.0 and above: Supports

    Firefox 25.0 and above: Supports

    Internet Explorer: No support

    Microsoft Edge: Supports

    Opera: Supports

    Safari 7.1 and above: Supports
因此,您需要修改类似于下面的代码才能在所有浏览器中工作

var index;
for(var i=0;i<people.length;i++){
  if(people[i].name == 'billi'){
   index = i
 }
}
var指数;
对于(var i=0;i而言,这是IE的最佳选择

people.findIndex(function(x){ x.name=="Bill" }));

你看到了吗?使用polyfill,例如。^^+IE11不支持ES6 arrow函数。你为什么这么认为?因为我测试了它,发现了同样的问题IE11不支持FindIndex方法,如果你想要该功能,你必须使用polyfill。