Skip to content
Subhajit Sahu edited this page May 11, 2020 · 26 revisions

Combines values from arrays. 🏃 📼 📦 🌔

Alternatives: [zip], [zipLongest].

array.zip(xs, [fn], [ths]);
// xs:  arrays
// fn:  map function (vs, i, xs)
// ths: this argument
const array = require('extra-array');

var x = [1, 2, 3];
var y = [4, 5, 6];
array.zip([x, y]);
// [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]

array.zip([x, y], ([a, b]) => a + b);
// [ 5, 7, 9 ]

references

Clone this wiki locally