array.filter(...).map(...).reduce(...)
Best for performance in many cases.
You reduce the number of elements early (via .filter()
).
Then you transform only the filtered subset (via .map()
).
Finally, you aggregate them (via .reduce()
).
Fewer elements to map and reduce = more efficient.