Get to know MDN better
Since March 2026, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
The Iterator.concat() static method creates a new Iterator object from a list of iterable objects. The new iterator yields the values from each of the input iterables in sequence.
An object that implements the iterable protocol. Iterators which are not also iterable cannot be passed directly to this method; they must first be wrapped using Iterator.from().
A new Iterator object that yields the values from each of the input iterables in sequence.
The Iterator.concat() method is conceptually similar to Array's concat() method, but it operates on any kind of iterable, and returns an iterator instead of an array. This means that the iterables can be lazily iterated, avoiding unnecessary allocation or computation. It also means that, technically, you can concatenate infinite iterables, but results from iterables after the first infinite iterable will never be reached.
While each iterable can be infinite, the list of iterables must be finite—and quite limited in number because engines impose a very low limit on the number of function arguments. If you need to concatenate a large—even infinite—number of iterables, use Iterator.prototype.flatMap() instead.
The Iterator.concat() method is similar in functionality to the following function, which uses the yield* operator to yield values from each of the input iterables in sequence:
Like yield*, Iterator.concat() doesn't support arguments that are not iterable (i.e., doesn't have the [Symbol.iterator]() method). This is because Iterator.concat() always takes ownership over its iterators and closes open iterators when the method exits. With iterable arguments, Iterator.concat() acquires iterators one-by-one and just closes the current iterator when the iteration is stopped. With iterator arguments, it's not clear whether the caller or Iterator.concat() should be responsible for closing the iterators, especially the ones that Iterator.concat() hasn't reached, so the method simply disallows non-iterable arguments.
In this example, we create a new Map that's the union of three other maps. The Map() constructor accepts an iterable of key-value pairs, while the Map iterator yields key-value pairs from the map, so just using Iterator.concat() on the maps is sufficient to create the new map.
Note that the value of key "a" in the resulting map is 5. This is because the Map constructor uses the last value for each key.
When any of the input iterables is infinite, the resulting iterator will also be infinite. This isn't immediately a problem because iterators can be consumed lazily and closed at any time, but it does mean that iterables after the first infinite iterable will never be reached.
You can concatenate iterables of different types.
The elements of each iterable can also be of different types, just like arrays.
Non-iterable objects throw a TypeError when passed to Iterator.concat() because they don't have the [Symbol.iterator]() method.
Because all built-in iterators extend the Iterator class, they are all iterable and can be passed to Iterator.concat().
To pass an iterator that isn't also iterable, you can wrap it using Iterator.from().
Another option is to use Iterator.prototype.flatMap() instead, which automatically calls Iterator.from(). But be careful: you need to call flatMap() on an iterator, not on an array, because Array.prototype.flatMap() only supports array return values.
When implementing your own iterators, consider making them iterable by or subclassing Iterator or adding a [Symbol.iterator]() method that returns this.
| ECMAScript® 2027 Language Specification # sec-iterator.concat |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jan 13, 2026 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.