DEV Community


Discussion on: JavaScript reduce() method

lexlohr profile image
Alex Lohr

I don't really get that "underwater" question. It is only iterating over the array once, whereas the filter/map variant will iterate once to create a filtered representation of the array and once more to map it.

And yes, the reduce will be somewhat faster, even though the native array methods are pretty optimized already.

Thread Thread
dailydevtips1 profile image
Chris Bongers Author

That was my question indeed if it actually is only 1 iteration.
Very cool stuff actually