Shallowly copy all of the properties in the source objects over to the destination object, and return the destination. It is in-order, so the last source overrides properties of the same name in previous arguments (official Underscore docs). Stable Object helper — not deprecated.
Pass the required arguments shown below. Underscore object helpers usually return a new value — check whether the source object is mutated.
Syntax
Call _.extend. Start with this line.
Underscore
_.extend(destination, *sources)
Call
What it does
_.extend(destination, *sources)
Primary signature.
_.extend(...)
Call with the arguments your case needs.
Load Underscore with import _ from "underscore" (or the UMD CDN build) so these helpers are available as _.
Library declarations
Underscore
_.extend(destination, *sources)
Parameters
Parameter
Description
destination
Required. Target object (mutated and returned)
*sources
Required. One or more objects to copy from
Return Value
Return Value
Description
*
The value returned by _.extend().
Underscore.js Examples
Example 1 — Merge Two Objects
Official-style merge: copy source properties onto the destination.
vs defaults(). Here later values always win — including overwriting with false/0.
Compatibility
Browser & Runtime Support
_.extend ships with Underscore.js (1.x). It runs anywhere Underscore runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install underscore. Similar job to native Object.assign (own props).
✓ Stable · Underscore 1.x
_.extend()
Available in [email protected] (UMD / ESM). Works in evergreen browsers and current Node LTS when Underscore is loaded.
100%With Underscore 1.x
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
_.extendUnderscore 1.x+
Bottom line: Safe for production once Underscore is on the page or in your bundle. Not a native browser API — load Underscore first. Prefer a pinned CDN version (e.g. [email protected]).
Frequently Asked Questions
_.extend(destination, *sources) shallowly copies properties from one or more sources into destination and returns destination. Later sources overwrite earlier ones for the same key.
Yes. It mutates the destination in place and returns it. Sources are not changed. Use _.extend({}, a, b) to avoid mutating an existing object.
_.extend copies enumerable properties, including inherited ones. _.extendOwn (alias _.assign) copies only own properties.
_.extend overwrites existing keys. _.defaults only fills keys that are undefined and never clobbers set values.
Shallow. Nested objects and arrays are copied by reference, not duplicated.
Merging configs, applying overrides on defaults, mixing properties into a target, or combining several plain objects in one call.