

I expect that the “ah-ha” moment will come further on, when looking at a visualization of how it works, or trying the problem exercises for yourself. The problem is, it’s a bit like trying to learn how to tie a shoelace using words alone you may be able to understand intellectually how it works… but good luck keeping your shoes on.

Some Words That Probably Won’t HelpĮvery explanation I’ve seen for reduce tries to explain how it works using English. Once you’ve gotten that stuff down, come on back. It’s probably also helpful if you know about and. Prerequisite Knowledge: I’ll be assuming you have an understanding of modern JavaScript, including arrow functions, enhanced object literals, and the array spread operator. It’s foundational to understanding Redux, and it’s also a really neat tool to have in your toolbelt. I had initially set out to write a blog post introducing Redux, but reduce warrants a blog post of its own. It’s like building muscle memory it takes a while for it to become intuitive and natural. Similar to recursion, you need to be able to keep track of the sequence of iterations in your head, and this can be a hard skill to develop.

Unlike those other array methods, each iteration in reduce is affected by the previous iteration’s return value.

That flexibility comes at a price, though: it’s pretty tough to get the hang of. Like those other methods, reduce is called on every item in the list, but the end result can be whatever you need an array of data, an object, a number. Reduce is an array method, similar in spirit to map and filter, but far more flexible. The more I thought about it, the more I realized that to understand Redux, you first need to understand. There are a lot of great resources for learning Redux, but few of them cover the fundamental knowledge you need to fully understand it. I volunteered to introduce Redux, a tool to manage front-end state.įor this reason, I found myself looking at how Redux is taught. As part of their onboarding, we host several brief talks introducing the technology we work with: React, Flow, Google AppEngine, and so on. Every summer, Khan Academy recruits a few software engineer interns.
