JS: Iterator.prototype.reduce
(new in JS: ECMAScript 2025)
iterator.reduce(args)
-
Similar to Array.prototype.reduce , but works on iterator.
Normally you can use this method on any Iterable, because all standard iterable objects are also Iterator.
// define a generator function function* gf() { for (let x of [1, 2, 3, 4, 5]) yield x; } const f = (x, y) => `f(${x} ${y})`; console.log( gf().reduce(f) === "f(f(f(f(1 2) 3) 4) 5)", ); // true
JavaScript. iterator helpers
- JS: Iterator.prototype.map
- JS: Iterator.prototype.forEach
- JS: Iterator.prototype.filter
- JS: Iterator.prototype.reduce
- JS: Iterator.prototype.take
- JS: Iterator.prototype.drop
- JS: Iterator.prototype.every
- JS: Iterator.prototype.some
- JS: Iterator.prototype.find
- JS: Iterator.prototype.flatMap
- JS: Iterator.prototype.toArray