Iterator Helpers Playground

ES2025 brings .map(), .filter(), .take() and more directly to Iterator.prototype. Explore each method interactively and see lazy evaluation in action.

ES2025 Baseline 2025
Chrome 122+ Firefox 131+ Safari 18.2+

.map(fn) Transform each value

Lazily applies fn to each yielded value, returning a new iterator.

map.jsCtrl+Enter to run

.filter(fn) Keep matching values

Yields only the values for which fn returns truthy.

filter.jsCtrl+Enter to run

.take(n) First n values

Yields at most n values, then closes the iterator. Works safely on infinite iterators.

take.jsCtrl+Enter to run

.drop(n) Skip first n values

Skips the first n values, then yields the rest.

drop.jsCtrl+Enter to run

.flatMap(fn) Map + flatten

Maps each value through fn (which must return an iterable or iterator) and flattens one level.

flatMap.jsCtrl+Enter to run

.reduce(fn, init) Accumulate into a single value

Consumes the iterator, reducing all values into a single result. Eager operation.

reduce.jsCtrl+Enter to run

.toArray() Collect into an array

Consumes the iterator and returns all yielded values as an Array.

toArray.jsCtrl+Enter to run

.forEach(fn) Execute side effects

Consumes the iterator, calling fn for each value. Returns undefined.

forEach.jsCtrl+Enter to run

.some(fn) Any match?

Returns true as soon as fn returns truthy for a value. Short-circuits.

some.jsCtrl+Enter to run

.every(fn) All match?

Returns true only if fn returns truthy for every value. Short-circuits on first false.

every.jsCtrl+Enter to run

.find(fn) First match

Returns the first value for which fn returns truthy, or undefined. Short-circuits.

find.jsCtrl+Enter to run

Lazy Evaluation Demo

Iterator helpers are lazy -- intermediate steps like .map() and .filter() only execute when a value is actually consumed. This demo proves it by logging which elements get processed.

lazy-proof.jsCtrl+Enter to run

Eager: Array methods

Click "Run Comparison" to see the difference.

Lazy: Iterator Helpers

Click "Run Comparison" to see the difference.

Pipeline Builder

Chain multiple iterator helpers visually. Add steps, configure arguments, and run the pipeline. Each step executes lazily.

source.values()