Calls a callback function for all the elements in an Iterable. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
Works like Array.prototype.reduce.
Sum all numbers
const sum = reduce((acc, curr) => acc + curr, 0);const result = sum([1, 2, 3]);console.log(result); // 6
filter, flatMap, map and sum for similar operations.
the reduced value
the Iterable value type
the reduce result type
reduce
the reducer Fucntion
the value for the first call of reducerFn
reducerFn
Generated using TypeDoc
Calls a callback function for all the elements in an Iterable. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
Works like Array.prototype.reduce.
Example
Sum all numbers
See
filter, flatMap, map and sum for similar operations.
Returns
the reduced value