I am trying to get an object in an array by the value of one of its keys.
Array:
var arr = [
{
city: 'Amsterdam',
title: 'This is Amsterdam!'
},
{
city: 'Berlin',
title: 'This is Berlin!'
},
{
city: 'Budapest',
title: 'This is Budapest!'
}
];
I tried to do something similar with help lodash, but did not succeed.
var picked = lodash.pickBy(arr, lodash.isEqual('Amsterdam');
and returns an empty object.
Any idea on how I can do this in a lodash way (if possible)? I can do this in a classic way by creating a new array, going through all the objects and clicking on those that match my criteria for this new array. But is there a way to do this with lodash?
This is not a duplicate.
source
share