I have the following array of objects :
var objs = [{id: 1, name: 'foo', ...},
{id: 2, name: 'bar', ...},
{id: 3, name: 'baz', ...}];
and this variable :
var matcher = 'bar';
What is the easiest way to get the object that has the matcher equals to its name ?
Using this matcher the result should be :
{id: 2, name: 'bar', ...}
$.grep, Another one suggestsArray.prototype.filter. Developers still use them. You just want to filter an object in array, a simple, very oldforloop can do this too. There is no need to use a 2015 tech for it. And the point of marking as duplicate is not "soling" a question.