Getting index of an array’s element based on its properties

var index = myArray.map(function(el) {
  return el.id;
}).indexOf(4);

For IE below version 9, map need a patch, or just use a loop.

Leave a Comment