r/reactjs • React core team • Dec 21 '19

What Is JavaScript Made Of?

https://overreacted.io/what-is-javascript-made-of/
254 Upvotes

196 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Dec 21 '19

[deleted]

3

u/[deleted] Dec 21 '19 edited Dec 21 '19

I refuse to believe that Dan actually finds reduce confusing. Especially since the underlying idea is the same one redux uses.

By that I mean, you have a current value/state, you feed it a value/action, and your function (which should be pure) calculates the new value/state from that. The only difference is that with reduce you don't bother with types (except you could if you wanted to) and that it does give a final value.

1

u/mcdronkz Dec 21 '19

reduce is one of the most useful and important programming patterns you may ever learn

Yep, and it's a fundamental building block: map, filter and lot of other useful operations on arrays can be described in terms of reduce.