i have javascript array of objects this:
var myarray = [{...}, {...}, {...}];
each object has unique id
among other properties:
{ id: 4, property1: 'something', property2: 'something' }
how can index of particular object in array, if know id
property? if know myarray[x].id == 4
, how can find x
?
var index = myarray.map(function(el) { return el.id; }).indexof(4);
for ie below version 9, map need patch, or use loop.
Comments
Post a Comment