What does reduce do in javascript

broken image
broken image

We haven’t touched on the reducer’s second argument however, the action.

broken image

This is ideal for doing something that we need to have reliable values for like managing state. In other words, they are the real-world example of the pure functions which, given a certain input, we will always have the same output with no side effects (an interaction with something outside our app that can change our state, such as an API) along the way. What is so special about this and why would we want to use it?įirst of all, reducers are special because they are predictable.

broken image

Enter fullscreen mode Exit fullscreen mode

broken image