I have a JavaScript array of objects like this:

var myArray = [{...}, {...}, {...}];

Each object has unique id among other properties:

{ 
  id: 4,
  property1: 'something',
  property2: 'something'
}

How can I get an index of a particular object in that array, if I only know its id property? So if I know that myArray[x].id == 4, how can I find x?

Edit
Report