Andurit Andurit - 1 year ago 506
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.

Answer Source

just use _.filter - it returns all matched items