JavaScript Iterator Iterator.concat() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Static method

Definition

Iterator.concat(it1, it2, /* ... */) builds one new iterator that yields every value from the first iterable, then the second, and so on. Nothing is copied into an array unless you ask for it.

Each argument must be iterable (it needs [Symbol.iterator]). Arrays, strings, Sets, and built-in iterators all work. A plain custom iterator that is not iterable should be wrapped with Iterator.from() first.

Remember
Iterator.concat(a, b, c)

yields a, then b, then c
lazy: values come one by one

arguments must be iterable
wrap plain iterators with Iterator.from()

finish with .toArray() when you need an array

Syntax

Pass one or more iterables. Read values with a loop, or call toArray() at the end.

JavaScript
const first = [1, 2].values();
const second = [3, 4].values();

const all = Iterator.concat(first, second).toArray();

console.log(all.join(", "));   // 1, 2, 3, 4
CallWhat it does
Iterator.concat(a, b)One iterator that yields a, then b.
Iterator.concat(a, b).toArray()Same idea, but collect every value into an array.
Iterator.concat(Iterator.from(it), more)Wrap a non-iterable iterator, then join more values.
[...a, ...b]The older array way. It builds a full array up front.

A newer JavaScript static method on Iterator. Call it as Iterator.concat(...). Support is recent, so feature-detect before you rely on it. Siblings: Iterator.from(), Iterator.zip(), Iterator.zipKeyed(), chunks(), drop(), every(), filter(), find(), flatMap(), forEach(), includes(), join(), map(), reduce(), some(), take(), toArray(), windows(), [Symbol.dispose](), [Symbol.iterator]().

Library declarations
JavaScript
// Newer Iterator static method
Iterator.concat(it1)
Iterator.concat(it1, it2)
Iterator.concat(it1, it2, /* ..., */ itN)

// it1, it2, ... : iterable objects
// returns       : a new Iterator

Parameters

ParameterDescription
it1, it2, …, itNOne or more iterables. Values are yielded in the order of the arguments. A value that is not iterable throws a TypeError.

Return Value

Return ValueDescription
IteratorA new iterator that yields every value from each argument, in order. It does not change the input iterables.

JavaScript Examples

Example 1 — Join Two Array Iterators

Take two arrays with .values(), join them with Iterator.concat(), and turn the result into one array.

JavaScript
const first = [1, 2].values();
const second = [3, 4].values();

const all = Iterator.concat(first, second).toArray();

console.log("Joined: " + all.join(", "));
console.log("Count: " + all.length);
Try It Yourself

The Try It page first checks that Iterator.concat() 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

  1. Make iterators. .values() turns each array into an iterator of its items.
  2. Join them. Iterator.concat(first, second) yields 1, 2, then 3, 4.
  3. Collect. toArray() reads every value into one array so join() can print it.

Example 2 — Mix a Generator with an Array

Join a small generator and an array iterator. The generator values come first.

JavaScript
function* letters() {
  yield "a";
  yield "b";
}

const nums = [1, 2].values();
const mixed = Iterator.concat(letters(), nums).toArray();

console.log("Mixed: " + mixed.join(", "));
console.log("Last: " + mixed[mixed.length - 1]);
Try It Yourself

The Try It page first checks that Iterator.concat() 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

  1. Generator first. letters() is iterable, so it can be passed straight to concat().
  2. Then numbers. After "a" and "b", the array iterator yields 1 and 2.
  3. One list. toArray() gives ["a", "b", 1, 2], which prints as one line of text.

Example 3 — Wrap with Iterator.from() Then Join

Build a third iterable with Iterator.from(), then concatenate three short sequences.

JavaScript
const a = [10].values();
const b = Iterator.from([20, 30]);
const c = [40].values();

const all = Iterator.concat(a, b, c).toArray();

console.log("All: " + all.join(", "));
console.log("Sum: " + all.reduce((s, n) => s + n, 0));
Try It Yourself

The Try It page first checks that Iterator.concat() 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

  1. Three sources. Two come from .values(), and the middle one from Iterator.from().
  2. One pass. concat() walks them left to right: 10, then 20, 30, then 40.
  3. Check the total. The joined array sums to 100, which confirms every value was included once.

Browser & Runtime Support

Iterator.concat() is a newer Iterator static method. Support landed in recent Chrome, Firefox and Safari builds. Always feature-detect before relying on it.

✓ Newer · Recent engines

Iterator.concat()

Supported in Chrome 146+, Edge 146+, Firefox 147+, Safari 26.4+, Opera 131+ and Node.js 24+. Internet Explorer never got it.

Recent Standard since
Google Chrome 146+ · Desktop & Mobile
Full support
Microsoft Edge 146+ · Chromium based
Full support
Mozilla Firefox 147+ · Desktop & Mobile
Full support
Apple Safari 26.4+ · macOS & iOS
Full support
Opera 131+ · Chromium based
Full support
Samsung Internet Recent · Android
Supported
Android WebView 146+ · Chromium based
Supported
Node.js 24+ · Server runtime
Supported
Deno Recent versions · JavaScript runtime
Supported
Bun Recent versions · JavaScript runtime
Supported
Internet Explorer No native support
Not supported
Iterator.concat() Recent engines

Bottom line: Feature-detect with typeof Iterator.concat === "function" (or the matching static name). Older engines can use a small generator with yield* instead.

Frequently Asked Questions

It joins several iterables into one new iterator. Values come from the first iterable, then the second, and so on, without building a big array unless you call toArray() or similar.
Yes. Arrays are iterable, so Iterator.concat([1, 2], [3, 4]) works. Using .values() is also fine when you already have iterators.
Every argument must be iterable. A bare next()-only object is not enough. Wrap it with Iterator.from(obj) first, then pass that wrapper to concat().
The idea is similar, but Iterator.concat() stays lazy and works with any iterables. Array concat() always returns a new array right away.
Chain .toArray() at the end, or use Array.from(...), or a for...of loop that pushes into an array. Prefer toArray() when you are already using Iterator helpers.

Next: Iterator.from()

Learn how to turn an iterable or a plain iterator into a proper Iterator so you can use helpers like map and toArray.

Iterator.from() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful