I have an array of objects which I would like to filter using a contains/any method on a property using underscore.
For example, if I had the following variables:
var people = [
{
name: 'Dave',
age: 26
},
{
name: 'Frank',
age: 23
}];
var allowedAges = [20, 23, 24];
I would like to use underscore to end up with a result like:
var allowedPeople = [];
_.each(_.where(people, { age: _.any()}), function (person) {
allowedPeople.push(person);
});
And there may also be occasions where allowedAges is an array of objects and id want to use the contains/any on the people array using a property of the objects in allowedAges.