Iterator methodsBaseline · Newly available
The Iterator object is an abstract base for objects that implement the iterator protocol. It provides methods common to built-in iterators, such as filter(), find(), map(), and reduce(). You can also use the static method Iterator.from() to convert an existing iterable into an Iterator.
Works in the latest version of every major browser, but older devices may not support it yet. Baseline since Mar 31, 2025.
Browser support
DesktopChrome
1–121Not supported
122+Supportedsince Feb 20, 2024
Current: 155Edge
12–121Not supported
122+Supportedsince Feb 23, 2024
Current: 154Firefox
1–130Not supported
131+Supportedsince Oct 1, 2024
Current: 157Safari
1–18.3Not supported
18.4+Supportedsince Mar 31, 2025
Current: 27MobileChrome Android
18–121Not supported
122+Supportedsince Feb 20, 2024
Current: 155Firefox Android
4–130Not supported
131+Supportedsince Oct 1, 2024
Current: 157Safari iOS
1–18.3Not supported
18.4+Supportedsince Mar 31, 2025
Current: 27How to use
Every current browser supports this, but it only became Baseline on Mar 31, 2025. Use it as a progressive enhancement, or keep a fallback if you support older devices.
Example
JS
function* naturals() {
let n = 1;
while (true) yield n++;
}
const firstEvenSquares = naturals()
.filter((n) => n % 2 === 0)
.map((n) => n * n)
.take(3)
.toArray(); // [4, 16, 36]Feature detection
JS · check before using
if ("Iterator" in Iterator || ("prototype" in Iterator && "Iterator" in Iterator.prototype)) {
// Iterator.Iterator is available
}Specification
Sub-features
Support for each part of the feature (13). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| Iterator.Iterator | 122 | 122 | 131 | 18.4 | 122 | 131 | 18.4 |
| Iterator.drop | 122 | 122 | 131 | 18.4 | 122 | 131 | 18.4 |
| Iterator.every | 122 | 122 | 131 | 18.4 | 122 | 131 | 18.4 |
| Iterator.filter | 122 | 122 | 131 | 18.4 | 122 | 131 | 18.4 |
| Iterator.find | 122 | 122 | 131 | 18.4 | 122 | 131 | 18.4 |
| Iterator.flatMap | 122 | 122 | 131 | 18.4 | 122 | 131 | 18.4 |
| Iterator.forEach | 122 | 122 | 131 | 18.4 | 122 | 131 | 18.4 |
| Iterator.from | 122 | 122 | 131 | 18.4 | 122 | 131 | 18.4 |
| Iterator.map | 122 | 122 | 131 | 18.4 | 122 | 131 | 18.4 |
| Iterator.reduce | 122 | 122 | 131 | 18.4 | 122 | 131 | 18.4 |
| Iterator.some | 122 | 122 | 131 | 18.4 | 122 | 131 | 18.4 |
| Iterator.take | 122 | 122 | 131 | 18.4 | 122 | 131 | 18.4 |
| Iterator.toArray | 122 | 122 | 131 | 18.4 | 122 | 131 | 18.4 |