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
This shaves a line off Ddi's iterator-based answer:
function* zip(...toZip) { const iterators = toZip.map((arg) => arg[Symbol.iterator]()); const next = () => toZip = iterators.map((iter) => iter.next()); while (next().every((item) => !item.done)) { yield toZip.map((item) => item.value); } }