reduce belongs to the Fold family and it's a powerful tool for structural transformations. However it is prone to increasing cognitive load when reviewing or simply reading code, see this video, when often a double pass with filter and map does just as well in performance as reduce, see this summary, while keeping cognitive load low. Also remember that JS is compiled, and some optimizations may happen to the code.
reduce
belongs to the Fold family and it's a powerful tool for structural transformations. However it is prone to increasing cognitive load when reviewing or simply reading code, see this video, when often a double pass withfilter
andmap
does just as well in performance asreduce
, see this summary, while keeping cognitive load low. Also remember that JS is compiled, and some optimizations may happen to the code.I'd definitely check those out. Thanks for contributing