Recursively merges own enumerable string-keyed properties of sources into the destination object. Part of Lodash Object since 0.5.0 (stable — not deprecated).
Warning:_.merge mutates the first argument and returns it. Pass _.merge({}, …sources) when you need a new object.
Syntax
Call _.merge. Start with this line.
Lodash
_.merge(object, [sources])
Call
What it does
_.merge(object, [sources])
Primary signature.
_.merge(object)
Work with an object’s keys, values, or paths.
Prefer import merge from "lodash/merge" when you want a smaller bundle.
Library declarations
Lodash
_.merge(object, [sources])
Parameters
This method has no parameters beyond those shown in the signature.
Return Value
Return Value
Description
*
The mutated destination
Lodash Examples
Example 1 — Official: Nested Array Objects
Plain objects inside arrays are merged index by index.
_.merge is a Lodash Object helper since 0.5.0. It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash.
✓ Stable · Lodash 0.5.0+
_.merge()
Available in [email protected] full builds and the lodash/merge modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.
100%With Lodash 0.5.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
_.mergeLodash 0.5.0+
Bottom line: Safe for production once Lodash is loaded. Prefer import merge from "lodash/merge" for smaller bundles. Remember it mutates the destination — use {} as dest when you need a fresh object.
Frequently Asked Questions
_.merge(object, …sources) recursively merges own enumerable string-keyed properties of sources into object. Official: merging nested array objects combines properties at each index.
Yes. The destination is updated in place and also returned. Use _.merge({}, a, b) when you want a fresh object.
_.assign is shallow: nested objects are replaced whole. _.merge walks into plain objects and arrays and merges them recursively.
By index, not concatenated. _.merge({items:[1,2,3]}, {items:[10]}) → {items:[10,2,3]}. For concat rules, use _.mergeWith.
undefined in a source is skipped; the destination value is kept. null overwrites like any other value.
Use import merge from "lodash/merge" or require("lodash/merge") for tree-shaking. Full build: import _ from "lodash" then _.merge.