根据数组对象某一元素的id,找到此元素在数组所在的位置(findIndex)

var listData = [
    {id:"1234",name:"bob"},
    {id:"2451",name:"mary"},
    {id:"6666",name:"tom"},
    {id:"5675",name:"jerry"},
    {id:"8421",name:"ken"},

]
let index = listData.findIndex( item => item.id == '8421');
console.log(index)  //4

 

你可能感兴趣的:(根据数组对象某一元素的id,findIndex)