iterator.map(callbackFn) walks the source iterator and calls callbackFn on each value. It returns a new lazy iterator that yields the callback results one by one — nothing is stored in an array until you pull values.
Because the result is still an iterator helper, you can chain other helpers such as filter() or take(), then finish with toArray() or a for...of loop when you need the values.
Remember
iterator.map(callbackFn)
each value → callback runs once
returns → a new lazy iterator (not an array)
pull values → toArray() or for...of
Start from .values() or a generator
Chain helpers, collect at the end
Syntax
Call map() on an iterator and pass a function that turns each value into a new one.
JavaScript
const it = [1, 2, 3].values();
const doubled = it.map((n) => n * 2);
console.log(doubled.toArray()); // [2, 4, 6]
Call
What it does
iterator.map(callbackFn)
Return a lazy iterator of callbackFn(value) for each source value.
// Iterator helpers (Baseline Newly available)
Iterator.prototype.map(callbackFn)
// callbackFn(value) : returns the mapped value
// returns : a new lazy iterator helper
Parameters
Parameter
Description
callbackFn
Required. Called once per value as callbackFn(value). Its return value is what the new iterator yields.
Return Value
Return Value
Description
Iterator helper
A new lazy iterator that yields mapped values. The source is not turned into an array automatically — use toArray() or loop with for...of when you need results.
JavaScript Examples
Example 1 — Map Values from an Array Iterator
Start with [1, 2, 3].values(), double each number, and collect the result with toArray().
The Try It page first checks that iterator.map() exists, because Iterator helpers are still new. In an older browser it prints a short explanation and the output above. In a current browser it runs the code for real.
How It Works
Get an iterator.[1, 2, 3].values() yields 1, then 2, then 3.
Map each value. The callback multiplies by 2, so the helper will yield 2, 4, 6.
Collect results.toArray() pulls every remaining value into a normal array for printing.
Example 2 — Chain map() with filter()
Map first, then keep only the large results. Helpers stay lazy until toArray().
JavaScript
const result = [1, 2, 3, 4, 5].values()
.map((n) => n * 10)
.filter((n) => n > 20)
.toArray();
console.log(result);
The Try It page first checks that iterator.map() exists, because Iterator helpers are still new. In an older browser it prints a short explanation and the output above. In a current browser it runs the code for real.
How It Works
Map to tens. Each number becomes 10, 20, 30, 40, 50.
Filter the large ones. Only values greater than 20 pass through.
Finish with an array.toArray() gives [30, 40, 50].
Example 3 — Map Values from a Generator
Build values with a small generator function, map them to strings, and print with for...of.
The Try It page first checks that iterator.map() exists, because Iterator helpers are still new. In an older browser it prints a short explanation and the output above. In a current browser it runs the code for real.
How It Works
Yield three letters. The generator produces "a", "b", and "c".
Map to uppercase. Each character becomes "A", "B", "C".
Loop to print.for...of pulls values one at a time without building an array first.
Compatibility
Browser & Runtime Support
Iterator.prototype.map() is an Iterator helper (Baseline Newly available since March 2025). It works in current browsers and in Node.js 22 or newer.
✓ Baseline 2025 · Newly available
iterator.map()
Supported in Chrome 122+, Edge 122+, Firefox 131+, Safari 18.4+, Opera 108+ and Node.js 22+. Internet Explorer never got it.
2025Standard since
Google Chrome122+ · Desktop & Mobile
Full support
Microsoft Edge122+ · Chromium based
Full support
Mozilla Firefox131+ · Desktop & Mobile
Full support
Apple Safari18.4+ · macOS & iOS
Full support
Opera108+ · Chromium based
Full support
Samsung Internet26+ · Android
Supported
Android WebView122+ · Chromium based
Supported
Node.js22+ · Server runtime
Supported
DenoRecent versions · JavaScript runtime
Supported
BunRecent versions · JavaScript runtime
Supported
Internet ExplorerNo native support
Not supported
iterator.map()Current browsers
Bottom line: Check support with a typeof test before you use it in older browsers. Prefer chaining helpers and calling toArray() last.
Frequently Asked Questions
It returns a lazy iterator that yields callbackFn(value) for each value from the source iterator. You usually finish with toArray() or for...of to see the results.
No. It returns another iterator helper. Call toArray() (or loop with for...of) when you want a normal array or printed values.
Only when someone pulls the next value from the mapped iterator. If you never consume it, the callback never runs.
Use array.values(), a generator, Iterator.from(...), or any object that already is an iterator with helpers.
Yes. Chain filter(), take(), drop(), and similar helpers, then collect once at the end with toArray() or a loop.