Applies a reducer function on each element of the iterable, in order, passing the return value from the operation on the previous element. The final result of running the reducer across all elements of the iterable is a single value.
reducer
The result of calling reducer on each item.
reduce([1, 2, 3, 4, 5], (x, y) => x + y, 0)// 15
Array.reduce()
The collection to reduce.
A reducer function that will be called per item.
Optional
Optional initial value (defaults to the first element in the iterable).
Generated using TypeDoc
Applies a
reducer
function on each element of the iterable, in order, passing the return value from the operation on the previous element. The final result of running the reducer across all elements of the iterable is a single value.Returns
The result of calling reducer on each item.
Example
See
Array.reduce()