How to find index of an object by key and value in an javascript array
- by return1.at
Given:
var peoples = [
{ "attr1": "bob", "attr2": "pizza" },
{ "attr1": "john", "attr2": "sushi" },
{ "attr1": "larry", "attr2": "hummus" }
];
Wanted:
Index of object where attr === value for example attr1 === "john" or attr2 === "hummus"
Update:
Please, read my question carefully, i do not want to find the object via $.inArray nor i want to get the value of a specific object attribute. Please consider this for your answers. Thanks!