ES5 and later versions of JavaScript brought several new methods for handling arrays. Many of them have become the best practice for common tasks w...
For further actions, you may consider blocking this person and/or reporting abuse
My favorite is a
pipe
method.It's just amazing that you can not only pass an array of objects, you can pass an array of functions, as a function is a first-class citizen in JavaScript.
And also, C# has a reduce method named Aggregate, which I think reflects more of what it does.
I like to use
reduce
when transforming lists, like creating aMap
from an array based on a key:Nice post. I have seen people using map to do something that can be easily done by reduce. But somehow I felt some developers don't know that reduce exists in the prototype of Array or they are hesitant to switch to reduce.
Yea, reduce is currently underrated for sure.
Great article, thanks Nicky for sharing!