Andurit Andurit - 2 years ago 579
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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download