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
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,找到此元素在数组所在的位置(find
本文链接:https://www.haomeiwen.com/subject/saiyfltx.html
网友评论