📜  索引本地存储对象 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:49.693000             🧑  作者: Mango

代码示例1
const data = [
  {id: 'jijijoj',rating: 'g'}, 
  {id: 'iojiojoi',rating: 'r'}, 
  {id: 'eawfe',rating: 'pg'}, 
  {id: 'ewfewfwe',rating: 'g'}, 
  {id: 'ewfewfew',rating: 'r'}
];

// get index of element with id `iojiojoi`
const index = data.findIndex(item => item.id === 'iojiojoi');

console.log(index);