Iterator.zip(iterables) walks several iterables together. Each step yields one array: the next value from every input, in the same order as the inputs.
By default it uses mode "shortest": when any input runs out, the zip stops. You can also pass options for "longest" or "strict" when lengths differ.
Remember
Iterator.zip([a, b])
step 1 → [a1, b1]
step 2 → [a2, b2]
default mode: "shortest"
stops when any input is done
use zipKeyed() when you want named keys
Syntax
Pass one iterable of iterables (often an array of iterators). Collect with toArray() when you want every pair.
JavaScript
const a = [1, 2].values();
const b = ["x", "y"].values();
const pairs = Iterator.zip([a, b]).toArray();
console.log(JSON.stringify(pairs)); // [[1,"x"],[2,"y"]]
Call
What it does
Iterator.zip([a, b])
Pair values from a and b into arrays.
Iterator.zip([a, b]).toArray()
Collect every pair into one array.
Iterator.zip([a, b], { mode: "longest" })
Keep going until the longest input ends; shorter ones pad with undefined by default.
// Newer Iterator static method
Iterator.zip(iterables)
Iterator.zip(iterables, options)
// iterables : iterable of iterables (not a bare iterator)
// options : optional { mode, padding }
// returns : a new Iterator of arrays
Parameters
Parameter
Description
iterables
Required. An iterable whose items are themselves iterable (or iterators). A common choice is an array such as [iterA, iterB]. It must be finite. Strings as top-level zip inputs are rejected; wrap them with Iterator.from() first.
options
Optional. An object with mode ("shortest", "longest", or "strict") and, for "longest", an optional padding iterable.
Return Value
Return Value
Description
Iterator
A new iterator. Each value is an array with one item from each input at that position.
JavaScript Examples
Example 1 — Pair Values from Two Iterators
Zip two short array iterators and print each pair as JSON text.
The Try It page first checks that Iterator.zip() 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
Two iterators..values() gives one number stream and one letter stream.
Zip them.Iterator.zip([nums, letters]) yields [1, "a"], then [2, "b"].
Collect.toArray() stores both pairs so JSON.stringify can print them.
Example 2 — Stop at the Shortest Input
Zip a longer list with a shorter one. By default, leftover values on the long side are ignored.
The Try It page first checks that Iterator.zip() 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
Unequal lengths. Left has three numbers; right has two letters.
Default mode."shortest" stops when right is done, so only two pairs are made.
Leftover. The number 3 is never paired, which the second log line states clearly.
Example 3 — Zip Three Iterables Together
Combine three short iterators. Each step is an array of three values.
JavaScript
const a = Iterator.from([1, 2]);
const b = Iterator.from(["p", "q"]);
const c = Iterator.from([true, false]);
const rows = Iterator.zip([a, b, c]).toArray();
console.log("First: " + JSON.stringify(rows[0]));
console.log("Second: " + JSON.stringify(rows[1]));
The Try It page first checks that Iterator.zip() 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
Three sources. Each list is turned into an Iterator with Iterator.from().
One zip. Every step pulls one value from each source into a length-3 array.
Print both rows. The first triple is [1, "p", true]; the second is [2, "q", false].
Compatibility
Browser & Runtime Support
Iterator.zip() is a newer Iterator static method for pairing values from several iterables. Support is still rolling out, so feature-detect first.
✓ Newer · Recent engines
Iterator.zip()
Supported in Chrome 146+, Edge 146+, Firefox 147+, Safari 26.4+, Opera 131+ and Node.js 24+. Internet Explorer never got it.
RecentStandard since
Google Chrome146+ · Desktop & Mobile
Full support
Microsoft Edge146+ · Chromium based
Full support
Mozilla Firefox147+ · Desktop & Mobile
Full support
Apple Safari26.4+ · macOS & iOS
Full support
Opera131+ · Chromium based
Full support
Samsung InternetRecent · Android
Supported
Android WebView146+ · Chromium based
Supported
Node.js24+ · Server runtime
Supported
DenoRecent versions · JavaScript runtime
Supported
BunRecent versions · JavaScript runtime
Supported
Internet ExplorerNo native support
Not supported
Iterator.zip()Recent engines
Bottom line: Feature-detect before use. A short manual loop that reads next() from each iterator can stand in on older engines.
Frequently Asked Questions
It walks several iterables at the same time. Each step yields one array with the next value from every input, so you can keep matching items together.
zip() takes one iterable of iterables. An array of iterators is the usual choice. Writing Iterator.zip(a, b) as two separate arguments is not the API.
By default, mode is "shortest": the result stops when any input ends. Use mode "longest" to keep going with padding, or "strict" to throw if lengths differ.
Use zipKeyed() when you want each step to be an object with named keys, such as { id, name }. Use zip() when a plain array pair is enough.
Not as top-level zip inputs in the usual way strings might look tempting. Convert them with Iterator.from("ab") (or similar) so each character is yielded as an iterator value.