Iterator helpers reach Baseline status

Iteration is a core part of everyday JavaScript. Developers typically rely on array methods like map, filter, and reduce to process data, but these utilities only work on arrays. When the data source is generic iterable, that means converting it to an array first—an operation that can be wasteful and, for infinite sequences produced by generator functions, simply impossible.

With iterator helpers now classified as Baseline Newly available, all major browsers support these methods directly on the Iterator prototype. This closes a long-standing gap in the language's functional programming toolkit.

What the helpers enable

The new methods mirror familiar array APIs but are tailored for iterator objects. The full set includes drop, every, filter, find, flatMap, forEach, map, reduce, some, take, and toArray.

A practical use case is DOM traversal. Working with a collection of list items, you can filter nodes by text content without first converting the NodeList to an array:

const posts = document.querySelectorAll("ul#specific-list > li")
  .values()
  .filter(item => item.textContent.includes("kiwi"));

// For-of loops can only be used on iterables, which `posts` is!
for (const post of posts) {
  console.log(post.textContent);
}

In this example, filter runs directly over the <li> elements, keeping only those whose innerText contains the substring "kiwi". The resulting iterator can then be consumed in a standard for loop.

Working with generators

Iterator helpers also compose cleanly with generator functions, which matters most when dealing with potentially unbounded sequences. A generator that produces factorials can pipeline those values through filter and take to land on specific outputs:

function* factorials (n) {
  let result = 1;

  for (let i = 1; i <= n; i++) {
    result *= i;

    yield result;
  }
}

const filteredFactorials = factorials(128).filter(x => x % 8 === 0);

console.log(filteredFactorials.next().value);
console.log(filteredFactorials.next().value);
console.log(filteredFactorials.next().value);
console.log(filteredFactorials.next().value);
console.log(filteredFactorials.next().value);

This example filters factorial values down to those divisible by 8 and logs the first five matches. Because the source sequence is infinite, materializing it as an array would never terminate—without these helpers, the task would require manual loop state. With them, declarative iteration works naturally.

Impact and resources

Iterator helpers significantly improve ergonomics for any code that consumes iterables, whether they come from generators, DOM APIs, or custom iterators. With Baseline status, developers can adopt the feature knowing cross-browser support is now consistent.

For deeper detail, refer to the V8 blog post on iterator helpers, the MDN documentation on iterator instance methods, and the TC39 proposal.