reduce() method applies a reducer Function to each
Array element, from left to right, by passing the reducer value
returned from the previous iteration and the next Array element
as parameters. The result of the last calculation is the returned value.
If the array has only one element the first element is returned.
If the array has no elements an error is returned. A mental
reduce() is that it is
fold() where the first
element is used as the seed.
The calling array isn’t changed.
Function to invoke for each element in the calling array, starting with the first value in the array.
Result of the last reducer calculation.
Reduce the Array elements to a single value:
Is this article helpful?
Tell Fauna how the article can be improved:
Thank you for your feedback!