DEV Community

Discussion on: Master the Javascript Array Reduce Method with 10 Examples

Collapse
 
ramgendeploy profile image
Ramiro - Ramgen • Edited

Those are awesome suggestions, the post was more to have examples on how to use reduce than the most performant way of doing things 😅,
as reduce is widely used on react and it's really useful to know how the vanilla javascript method works,
but yea knowing the best way of doing things is important.
I appreciate the time you have put in the comment, Thanks 😄

Collapse
 
fbolaji profile image
Francis.B

I rarely use Reduce in react as there more efficient methods to manipulate data as @lukeshiru mentioned.
I personal use all eas6 methods in React most of the time:
.filter()
.map()
new Set()
.find()
.findIndex()
.includes()
Object.is()
[].entries()
[].keys()
[].values()
.sort()
and untility library such as lodash
then occasionally .reduce() .some()

Thread Thread
 
ramgendeploy profile image
Ramiro - Ramgen

I also rarely use reduce in react, but I was working with the context api the other day and it really was useful to know how the reduce method worked to understand the api (at least the part where there is reduce like syntax), but yea with array manipulation reduce is at the bottom of the list 😅

Collapse
 
pengeszikra profile image
Peter Vivo

reducer in React means total different things, than array reduce function ... which is really useful tool as you described. reducer in React means pure function which modify state by action payload.

Thread Thread
 
ramgendeploy profile image
Ramiro - Ramgen

Yes you are correct, they are not the same, Thank for the comment.