user2981300
user2981300

Reputation: 21

underscore - filtering two dimensional array

I am trying to filter two-dimensional array like var arr = [ [object, object], [object, object], [object, object] ] and return the same structure. Any ideas?

Upvotes: 1

Views: 1219

Answers (1)

Bergi
Bergi

Reputation: 664444

A combination of filter and map will do it:

_.map(arr, function(subarr) {
    return _.filter(subarr, itemcondition)
})
// or:
_.map(arr, _.partial(_.filter, _, itemcondition));

Upvotes: 1

Related Questions