Standard built-ins
Iterator.prototype.reduce()
Consumes the sequence into an accumulator. Without an initial value, an empty sequence throws TypeError.
Formal Syntax & Structure
javascript syntaxjavascript
iterator.reduce(reducer[, initialValue])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| reducer | function | Accumulator callback. |
| initialValue | any | Optional starting accumulator. |
Return Value
any
Result of the operation.
Working Example
Example Snippetjavascript
console.log(JSON.stringify(Iterator.from([1,2,3]).reduce((a,b)=>a+b,0)));