Iterators and the for...of loopBaseline · Widely available
The for...of loop operates on a sequence of values sourced from an iterable object, such as arrays, array-like objects, DOM collections, iterators, generators, and user-defined iterables. All built-in iterators inherit from the Iterator class.
Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Jul 29, 2015. Widely available since Jan 29, 2018.
Browser support
DesktopChrome
1–37Not supported
38+Supportedsince Oct 7, 2014
Current: 155Edge
12+Supportedsince Jul 29, 2015
Current: 154Firefox
1–12Not supported
13+Supportedsince Jun 5, 2012
Current: 157Safari
1–6Not supported
7+Supportedsince Oct 22, 2013
Current: 27MobileChrome Android
18–37Not supported
38+Supportedsince Oct 8, 2014
Current: 155Firefox Android
4–10Not supported
14+Supportedsince Jun 26, 2012
Current: 157Safari iOS
1–6Not supported
7+Supportedsince Sep 18, 2013
Current: 27How to use
This feature is Baseline widely available — use it freely, no fallback needed.
Example
Full syntax and examples are on MDN: Iterator.
Feature detection
JS · check before using
if (typeof Iterator !== "undefined") {
// Iterator is available
}Documentation (MDN)
Sub-features
Support for each part of the feature (4). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| Iterator | 38 | 12 | 17 | 10 | 38 | 17 | 10 |
| Iterator.@@iterator | 38 | 12 | 36 | 10 | 38 | 36 | 10 |
| for_of | 38 | 12 | 13 | 7 | 38 | 14 | 7 |
| for_of.closing_iterators | 51 | 14 | 53 | 7 | 51 | 53 | 7 |