Pick. Index rules → merge; list append → mergeWith.
Both. Use {} so sources stay clean.
Compatibility
Browser & Runtime Support
_.mergeWith is a Lodash Object helper since 4.0.0. It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash.
✓ Stable · Lodash 4.0.0+
_.mergeWith()
Available in [email protected] full builds and the lodash/mergeWith modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.
100%With Lodash 4.0+
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
_.mergeWithLodash 4.0.0+
Bottom line: Safe for production once Lodash 4+ is loaded. Prefer import mergeWith from "lodash/mergeWith" for smaller bundles. Remember it mutates the destination — and return undefined to keep default merge for a key.
Frequently Asked Questions
_.mergeWith(object, …sources, customizer) deep-merges like _.merge, but calls customizer for each property so you can override how values combine. Official: concat arrays instead of merging by index.
Lodash falls back to its normal merge behavior for that property (recurse into plain objects/arrays, otherwise assign).
Yes. The destination is updated in place and returned. Use _.mergeWith({}, …sources, customizer) for a fresh object.
Typically (objValue, srcValue, key, object, source, stack). Return the merged value, or undefined to let Lodash continue.
_.merge always uses built-in rules (arrays by index). _.mergeWith lets you replace those rules — e.g. concatenate arrays.
Use import mergeWith from "lodash/mergeWith" or require("lodash/mergeWith") for tree-shaking. Full build: import _ from "lodash" then _.mergeWith.