lodash filter array of objects by array of exclude property values I ran into a scenario, I'll simplify the data to user/project, where I needed to take values like:

users: [
  {name: 'bob', project: 1},
  {name: 'sam', project: 2},
  {name: 'ted', project: 3},
];


and given an array of project ids I wish to exclude such as 

excludeProjects: [1,3];


I want to return [{name: 'sam', project: 2}];

I was able to do this with a custom filter function:

let usersNotInProject = _.filter(users, function(o) { 
    for (var i=0; i&lt;excludeProjects.length; i++){
        if (excludeProjects[i]===o.project){
            return false;
        }
    }
    return true;
});


However, I believe I am missing some more elegant way to do this with lodash. Is a custom function really needed for this scenario?
You can do it with filter:

let users = [
  {name: 'bob', project: 1},
  {name: 'sam', project: 2},
  {name: 'ted', project: 3},
];
let excludeProjects = [1,3];
_.filter(users, (v) =&gt; _.indexOf(excludeProjects, v.project) === -1) // assign it to some variable
// Returns [ { name: 'sam', project: 2 } ]


OR other way of doing it is suggested in comments, this is more elegant: 

_.filter(users, (v) =&gt; !_.includes(excludeProjects, v.project));
// Returns [ { name: 'sam', project: 2 } ]