DEV Community

Discussion on: Need help understanding: Filtering an array of objects in Javascript

Collapse
 
dmfay profile image
Dian Fay

The reduce accumulator doesn't have to be one value -- it's quite useful in places you'd use both filter and map to choose some elements of an array and generate derived values, and you only have to traverse the array once.

Collapse
 
gmartigny profile image
Guillaume Martigny

For large data set I would agree (even tho I never thought of it). But for sub 100 items, the lose in clarity isn't much worth it.