Lodash _.zipWith() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Array

Definition

Like _.zip, but an iteratee combines each aligned group of values. The iteratee is invoked with (...group) — one value from each array at that index. Part of Lodash 4.x Array.

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

Syntax

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

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

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

Library declarations
Lodash
_.zipWith([arrays], [iteratee=_.identity])

Parameters

ParameterDescription
arraysRequired. Parallel columns to combine
iterateeOptional. Combiner; default identity (like zip)

Return Value

Return ValueDescription
*New array of combined values

Lodash Examples

Example 1 — Official: Three-Way Sum

Each index receives one value from every array, then adds them.

Lodash
_.zipWith([1, 2], [10, 20], [100, 200], function (a, b, c) {
  return a + b + c;
});
// → [111, 222]
Try It Yourself

How It Works

  1. Index 0. Iteratee gets 1, 10, 100 → 111.
  2. Index 1. Iteratee gets 2, 20, 200 → 222.
  3. Arity. Three arrays → three iteratee arguments.
  4. Result. Flat array of combined numbers — no inner tuples.

Example 2 — Pairwise Addition

Two columns reduce to one total per row.

Lodash
_.zipWith([1, 2], [10, 20], function (a, b) {
  return a + b;
});
// → [11, 22]
Try It Yourself

How It Works

  1. Align. Same index in each array belongs together.
  2. First row. 1 + 10 = 11.
  3. Second row. 2 + 20 = 22.
  4. Use. Ledger-style column merges without building tuples first.

Example 3 — Build Labeled Strings

Any return type works — here, formatted label:value strings.

Lodash
_.zipWith(["score", "bonus"], [100, 25], function (label, n) {
  return label + ":" + n;
});
// → ["score:100", "bonus:25"]
Try It Yourself

How It Works

  1. Columns. Labels in one array, numbers in the other.
  2. Combine. Iteratee joins them with ":".
  3. Output. Two strings, one per index.
  4. Tip. You can return objects the same way.

Example 4 — Math.max Across Three Arrays

Pass a built-in that already accepts multiple arguments.

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

How It Works

  1. Index 0. Math.max(1, 4, 2) → 4.
  2. Index 1. Math.max(8, 3, 9) → 9.
  3. No wrapper. Math.max already takes variadic numbers.
  4. Result. Row-wise maxima without nested loops.

Example 5 — Omit Iteratee (= _.zip)

Without a combiner, you get the same nested tuples as _.zip.

Lodash
_.zipWith(["a", "b"], [1, 2]);
// → [["a", 1], ["b", 2]]

_.zipWith([1, 2, 3], [10], function (a, b) {
  return a + (b || 0);
});
// → [11, 2, 3]
Try It Yourself

How It Works

  1. No iteratee. Default identity keeps grouped values as tuples.
  2. Ragged. Second example passes undefined for missing b.
  3. Guard. b || 0 turns missing slots into zero.
  4. Length. Result length follows the longest input.

Browser & Runtime Support

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

✓ Stable · Lodash 4.x

_.zipWith()

Available in [email protected] full builds and the lodash/zipWith 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
_.zipWith Lodash 4.x+

Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import zipWith from "lodash/zipWith" for smaller builds. Not a native browser API — load Lodash first.

Frequently Asked Questions

_.zipWith(...arrays, iteratee) is like _.zip, but each aligned group of values is passed to iteratee. The return value of iteratee becomes that index’s result.
No. It returns a new array. The source arrays stay unchanged.
Last. Pass every array first, then the iteratee: _.zipWith(a, b, (x, y) => x + y). Omitting it behaves like _.zip.
One value from each array at the current index. Two arrays → (a, b); three → (a, b, c). Missing slots are undefined when lengths differ.
zipWith starts from parallel columns and merges forward per index. unzipWith starts from row tuples, pivots to columns, then folds each column.
Use import zipWith from "lodash/zipWith" or require("lodash/zipWith") for tree-shaking. Full build: import _ from "lodash" then _.zipWith.

Explore more array methods

Browse the full Lodash array helpers hub for the next topic.

Array methods hub →

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.

10 people found this page helpful