coderef

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: 155
Edge
12+Supportedsince Jul 29, 2015
Current: 154
Firefox
1–12Not supported
13+Supportedsince Jun 5, 2012
Current: 157
Safari
1–6Not supported
7+Supportedsince Oct 22, 2013
Current: 27
MobileChrome Android
18–37Not supported
38+Supportedsince Oct 8, 2014
Current: 155
Firefox Android
4–10Not supported
14+Supportedsince Jun 26, 2012
Current: 157
Safari iOS
1–6Not supported
7+Supportedsince Sep 18, 2013
Current: 27

How 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
}

Sub-features

Support for each part of the feature (4). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
Iterator38121710381710
Iterator.@@iterator38123610383610
for_of381213738147
for_of.closing_iterators511453751537