We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Combine values from arrays.
Similar: cartesianProduct, zip.
function zip(xs, fm, fe, vd?) // xs: arrays // fm: map function (vs, i) // fe: end function (dones) [some] // vd: default value
const xarray = require('extra-array'); var x = [1, 2, 3]; var y = [4, 5]; xarray.zip([x, y]); // → [ [ 1, 4 ], [ 2, 5 ] ] (shortest) xarray.zip([x, y], ([a, b]) => a + b); // → [ 5, 7 ] xarray.zip([x, y], null, xarray.some); // → [ [ 1, 4 ], [ 2, 5 ] ] (shortest) xarray.zip([x, y], null, xarray.every, 0); // → [ [ 1, 4 ], [ 2, 5 ], [ 3, 0 ] ] (longest) xarray.zip([x, y], null, xarray.head, 0); // → [ [ 1, 4 ], [ 2, 5 ], [ 3, 0 ] ] (first)