79493819

Date: 2025-03-08 03:20:28
Score: 0.5
Natty:
Report link

Use the indexOf method with the object you are looking for.

let index = aaa.indexOf(bbb);

So full script would be...

const aaa = [
  {id: 10, val: "xx"},
  {id: 27, val: "tr"},
  {id: 13, val: "ut"}
]

const bbb = aaa.find(obj => (obj.id === 27) );

let index = aaa.indexOf(bbb);

console.log(index); 

Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: stuartb