DEV Community

Discussion on: You don't need Array.reduce()

Collapse
 
kepta profile image
Kushan Joshi • Edited

Keeping the functional programming jargon aside, reduce might be difficult to read for people familiar with imperative style of programming. You need to focus on the part that reduce reduces the cognitive load from your head (of course after you understand how it works). You will appreciate that all you need to care about is the function that you pass to the reduce. There is not outer references that you need to be bothered about. You can even move this function to a new file and it would make sense to any fellow developer( It’s called code decoupling), because everything is self contained! no need to worry about some variable in the outer context. You can google more about the benefits of code decoupling.