Javascript equivalent of Python’s zip function

Is there a javascript equivalent of Python’s zip function? That is, given multiple arrays of equal lengths create an array of pairs.

For instance, if I have three arrays that look like this:

var array1 = [1, 2, 3];
var array2 = ['a','b','c'];
var array3 = [4, 5, 6];

The output array should be:

var output array:[[1,'a',4], [2,'b',5], [3,'c',6]]

24 Answers
24

Leave a Comment