I have a collection of objects and I need to search for instances where certain properties match specific values.
Here is an example array:
let arr = [
{
a: 'foo',
b: 'bar'
},
{
a: 'bar',
b: 'baz'
},
{
a: 'foo',
b: 'baz'
}
];
I want to filter the array to include objects that have a property with the value 'foo'.
Is there a way to achieve this using lodash? Perhaps something similar to the following:
_.filter(arr, function(obj) {
return obj.anyPropertiesMatch('bar');
});