# Zip multiple arrays

Pair the n-th items of several arrays.

Canonical: https://1loc.dev/array/zip-multiple-arrays/
Version: 1.0.0
Runtime: JavaScript · Node.js 22 / modern browsers
Verification: Local fixtures; no external services
Updated: 2026-10-28

## Implementation

```javascript
function zip(arrays) { return Array.from({ length: Math.max(0, ...arrays.map(array => array.length)) }, (_, i) => arrays.map(array => array[i] ?? null)); }
```

## Input

```json
[
  [
    "ana@example.com",
    "rui@example.com"
  ],
  [
    "delivered",
    "deferred"
  ]
]
```

## Expected output

```json
[
  [
    "ana@example.com",
    "delivered"
  ],
  [
    "rui@example.com",
    "deferred"
  ]
]
```

## Edge case

Input:
```json
[
  [
    "a",
    "b"
  ],
  [
    1
  ]
]
```
Output:
```json
[
  [
    "a",
    1
  ],
  [
    "b",
    null
  ]
]
```

## Limits

- Missing items become null (undefined in the original) so the result is JSON-representable.
- The original took arrays as separate arguments.

The lab validates types and size before calling this function. Add equivalent validation at your own trust boundary.

## Source and license

Original: https://github.com/phuocng/1loc/blob/14b481cf60dff1620ab1bb99a43b1f68068cdd9b/contents/zip-multiple-arrays.mdx
Author: Nguyen Huu Phuoc and original contributors
Contributors: See original repository history
Source commit: 14b481cf60dff1620ab1bb99a43b1f68068cdd9b
Copyright (c) 2020 phuoc-ng
License: MIT — https://1loc.dev/licenses/
Maintainer: Oveyon
Modifications: Takes one array of arrays; missing items become null so the result is JSON-representable. Original MDX retained as inert source evidence.
