例子:

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

//找不到返回-1
let index = listData.findIndex( item => item.id == '8888')
console.log(index)  //-1

  


 
                    
            
                

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-12
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
猜你喜欢
  • 2022-12-23
  • 2021-08-23
  • 2021-07-13
  • 2021-05-30
  • 2022-12-23
  • 2021-11-18
相关资源
相似解决方案