DEV Community

talent
talent

Posted on

Javascript reduce method explained!

JavaScript

In JavaScript functions composition is the backbone pattern of the functional programming.

Take a function, "reducing" it with something (a value or even another function), and taking its output and feed the next function with it.

Repeat the cycle.

The "reduce" method is the way all of this can be done.

How to implement a custom reduce method?

See illustration below:

Image description

Top comments (1)

Collapse
 
jonrandy profile image
Jon Randy ๐ŸŽ–๏ธ

Why the random mention of function composition?