JavaScript Answers

How to zip two arrays in JavaScript?

Spread the love

To zip two arrays in JavaScript, we use the map method.

For instance, we write

const a = [1, 2, 3];
const b = ["a", "b", "c"];

const c =, i) => {
  return [e, b[i]];


to call with a callback that returns an array with arrays of items in a and the items in b at the same position as the item in a.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published.