DEV Community

Discussion on: Javascript: how to merge multiple objects with sum of values

 
patarapolw profile image
Pacharapol Withayasakpunt

I think Array.reduce is more like recursive function, rather than taking advantage of mutability.

Thread Thread
 
timhlm profile image
moth

This is right on the money. There’re certain times when mutating things makes sense, and others when generating a new array with reduce is a better choice. It’s all about knowing when to use the right tool.