# Iterator.concat()

> The `Iterator.concat()` static JS method creates an iterator that yields values from several iterables in sequence.

## How do I concatenate iterators in JavaScript?

The static method that returns a new iterator yielding all values of the first iterable, then all values of the second one, and so on. Allows combining sequences lazily without creating intermediate arrays.

- Topic: Iterator
- Type: method
- Browser support: Chrome 146+, Chrome Android 146+, Edge 146+, Firefox 147+, Firefox Android 147+, Safari 26.4+, Safari iOS 26.4+

## Example

Wrong:

```js
const all = [...defaults, ...userItems];
for (const item of all) render(item);
```

Right:

```js
const all = Iterator.concat(defaults, userItems);
for (const item of all) render(item);
```

`Iterator.concat()` walks both sources in order without allocating a combined array.

## Common mistakes

- Iterating the result twice and getting nothing the second time.

## Key points

- `Iterator.concat()` is used instead of spreading into an array when the values are only iterated.
- The result is iterated only once, it is not reused after it is consumed.

## Interview questions

### Can I pass an object with only `next()` to `Iterator.concat()`?

No. Each argument must be an iterable with `Symbol.iterator`; wrap such an object with `Iterator.from()` first.

### Can I pass strings to `Iterator.concat()`?

No. Arguments must be objects, so a string throws a `TypeError`; pass `Iterator.from(str)` or `[...str]` instead.

## Related cards

- [Iterator](https://wonderium.dev/js/iterator.md)
- [Iterator.from()](https://wonderium.dev/js/iterator-from.md)
- [Array.concat()](https://wonderium.dev/js/array-concat.md)
- [Generator](https://wonderium.dev/js/generator.md)

---

- Level: [JavaScript](https://wonderium.dev/js.md)
- HTML version: https://wonderium.dev/js/iterator-concat
- Last updated: 2026-11-25
