Iterator Helpers

ES2025 added array-like methods to Iterator.prototype, inherited by every generator and built-in iterator (Chrome 122 1 , Firefox 131 555 , Safari 18.4 10 , Node.js 22 2,131 ). They are lazy: the chain pulls one value at a time, builds no intermediate arrays and copes with infinite sequences. Iterator.from() adds the helpers to a bare iterator.

Iterator helper methods
Method Evaluation
map(), filter(), flatMap(), take(n), drop(n) Lazy; return a new iterator
reduce(), toArray(), forEach() Eager; consume everything
some(), every(), find() Eager; stop at the answer
A lazy pipeline over an infinite generatorJavaScriptLive
const produced = [];
function* naturals() {
  for (let n = 1; ; n++) { produced.push(n); yield n; }
}
const evenSquares = naturals().filter(n => n % 2 === 0).map(n => n * n).take(2);
console.log(produced.length, evenSquares.toArray(), produced);   // lazy: pulled on demand
const sevens = { next: () => ({ value: 7, done: false }) };      // a bare iterator
console.log(Iterator.from(sevens).drop(1).take(3).reduce((a, b) => a + b));

Helpers consume their source, so an iterator cannot be replayed. flatMap() throws if the callback returns a string. Async iterator helpers are still a Stage 2 proposal; use for await...of (Asynchronous Iteration) for streams.