Andurit Andurit - 5 months ago 110x
Javascript Question

lodash _.find all matches

I have simple function to return me object which meets my criteria.

Code looks like:

var res = _.find($state.get(), function(i) {
var match =;
return match &&
(!i.restrict || i.restrict($rootScope.user));

How can I find all results (not just first) which meets this criteria but all results.

Thanks for anz advise.


just use _.filter - it returns all matched items