Recently, I encountered a dilemma with a JavaScript array containing objects structured like such:
var myArray = [{...}, {...}, {...}];
Within each object lies a unique id
, along with other properties:
{
id: 4,
property1: 'something',
property2: 'something'
}
The burning question is how exactly can one determine the index of a specific object in this array solely based on its id
? For instance, if we are aware that myArray[x].id == 4
, what steps should be taken to find out the exact value of x
?