Lodash _.unzipWith() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Array

Definition

Like _.unzip, but you pass an iteratee that combines each regrouped column. The iteratee is invoked with the elements of each group: (...group). Since Lodash 3.8.0.

Pass the required arguments shown below. Lodash Array helpers usually return a new value — check whether the source array is mutated.

Syntax

Call _.unzipWith on an array. Start with this line.

Lodash
_.unzipWith(array, [iteratee=_.identity])
CallWhat it does
_.unzipWith(array, [iteratee=_.identity])Primary signature.
_.unzipWith(array)Call with an array argument.

Prefer import unzipWith from "lodash/unzipWith" when you want a smaller bundle.

Library declarations
Lodash
_.unzipWith(array, [iteratee=_.identity])

Parameters

ParameterDescription
arrayRequired. Array of grouped elements (rows)
iterateeOptional. Default identity → like unzip

Return Value

Return ValueDescription
*The value returned by _.unzipWith().

Lodash Examples

Example 1 — Official: Sum Columns With _.add

Unzip zipped rows and add each column — from the Lodash docs.

Lodash
var zipped = _.zip([1, 2], [10, 20], [100, 200]);
// → [[1, 10, 100], [2, 20, 200]]

_.unzipWith(zipped, _.add);
// → [3, 30, 300]
Try It Yourself

How It Works

  1. zip builds two rows of three values each.
  2. Unzip regroups into columns [1,2], [10,20], [100,200].
  3. _.add sums each column: 3, 30, 300.
  4. Result. New array; source unchanged.

Example 2 — Column Maximums

Use Math.max to keep the largest value in each column.

Lodash
_.unzipWith(
  [
    [3, 8, 1],
    [5, 2, 9]
  ],
  Math.max
);
// → [5, 8, 9]
Try It Yourself

How It Works

  1. Col 0: Math.max(3, 5) → 5.
  2. Col 1: Math.max(8, 2) → 8.
  3. Col 2: Math.max(1, 9) → 9.
  4. Note. Math.max accepts multiple args — perfect for (...group).

Example 3 — Join Column Strings

Custom iteratee joins each column with a separator.

Lodash
_.unzipWith(
  [
    ["a", "x"],
    ["b", "y"],
    ["c", "z"]
  ],
  function () {
    return Array.prototype.slice.call(arguments).join("-");
  }
);
// → ["a-b-c", "x-y-z"]
Try It Yourself

How It Works

  1. Three rows of two cells each → two columns.
  2. Col 0: "a", "b", "c" → "a-b-c".
  3. Col 1: "x", "y", "z" → "x-y-z".
  4. Tip. Use rest params in modern JS: (...vals) => vals.join("-").

Example 4 — unzip vs unzipWith

unzip returns column arrays; unzipWith returns folded values.

Lodash
var rows = [[1, 10], [2, 20]];

_.unzip(rows);
// → [[1, 2], [10, 20]]

_.unzipWith(rows, _.add);
// → [3, 30]
Try It Yourself

How It Works

  1. unzip stops after regrouping into columns.
  2. unzipWith continues and folds each column.
  3. Same regroup step; only the fold differs.
  4. Omit iteratee on unzipWith → same shape as unzip.

Example 5 — Weighted Column Fold

Custom iteratee: average of each column.

Lodash
_.unzipWith(
  [
    [10, 100],
    [20, 200],
    [30, 300]
  ],
  function () {
    var vals = Array.prototype.slice.call(arguments);
    var sum = 0;
    for (var i = 0; i < vals.length; i++) sum += vals[i];
    return sum / vals.length;
  }
);
// → [20, 200]
Try It Yourself

How It Works

  1. Col 0: (10+20+30) / 3 → 20.
  2. Col 1: (100+200+300) / 3 → 200.
  3. Any fold works — sum, avg, product, object merge.
  4. Ragged rows may pass undefined; guard if needed.

Browser & Runtime Support

_.unzipWith is a Lodash Array helper (since 3.8.0). It runs anywhere Lodash 4.x runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash.

✓ Stable · Lodash 3.8.0+

_.unzipWith()

Available in [email protected] full builds and the lodash/unzipWith modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.

100% With Lodash 4.x
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
_.unzipWith Lodash 3.8.0+

Bottom line: Safe for production once Lodash is loaded. Prefer import unzipWith from "lodash/unzipWith" for smaller builds. Pair with _.add or a custom fold.

Frequently Asked Questions

_.unzipWith(array, iteratee) regroups rows into columns (like _.unzip), then combines each column by calling the iteratee with that column’s values as arguments (...group).
No. It returns a new array of combined column results. The source is unchanged.
It behaves like plain _.unzip — each column stays an array instead of a reduced value.
zipWith merges parallel arrays with an iteratee per index. unzipWith starts from grouped rows, pivots to columns, then folds each column.
One argument per row for that column — first row’s value, second row’s value, and so on. Missing slots from short rows are undefined.
Use import unzipWith from "lodash/unzipWith" or require("lodash/unzipWith") for tree-shaking. Full build: import _ from "lodash" then _.unzipWith.

Next: _.without()

Create a new array excluding given values (immutable filter).

_.without() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful