Underscore.js _.extendOwn() Method

Beginner
5 min read
Updated: Nov 2026
4 examples
Object

Definition

Like _.extend, but only copies own properties over to the destination object (official Underscore docs).

Pass the required arguments shown below. Underscore object helpers usually return a new value — check whether the source object is mutated.

Syntax

Call _.extendOwn. Start with this line.

Underscore
_.extendOwn(destination, *sources)
CallWhat it does
_.extendOwn(destination, *sources)Primary signature.
_.extendOwn(...)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
_.extendOwn(destination, *sources)

Parameters

ParameterDescription
destinationRequired. Object to receive properties (mutated)
*sourcesOptional. Objects whose own props are copied

Return Value

Return ValueDescription
*The same destination object

Underscore.js Examples

Example 1 — Basic Own-Property Merge

Copy own keys from sources into the destination.

Underscore
_.extendOwn({ a: 1 }, { b: 2 }, { c: 3 });
// → { a: 1, b: 2, c: 3 }
Try It Yourself

How It Works

  1. Destination. Starts as { a: 1 }.
  2. Sources. b and c are copied in order.
  3. Return. Same object reference, now with three keys.
  4. Alias. _.assign does the same thing.

Example 2 — Skip Inherited Properties

Unlike _.extend, prototype properties are not copied.

Underscore
var proto = { inherited: true };
var src = Object.create(proto);
src.own = "yes";

_.extendOwn({}, src);
// → { own: "yes" }

_.extend({}, src);
// → { own: "yes", inherited: true }
Try It Yourself

How It Works

  1. Setup. src has own own and inherits inherited.
  2. extendOwn. Copies only own.
  3. extend. Also copies enumerable inherited inherited.
  4. Pick. Want Object.assign-like behavior → extendOwn.

Example 3 — Later Sources Overwrite

When keys collide, the rightmost source wins.

Underscore
_.extendOwn({ x: 1 }, { x: 2, y: 3 }, { y: 4 });
// → { x: 2, y: 4 }
Try It Yourself

How It Works

  1. Start. Destination has x: 1.
  2. Second. Sets x: 2 and adds y: 3.
  3. Third. Overwrites y to 4.
  4. Order. Sources apply left to right.

Example 4 — Fresh Destination (No Mutate Source)

Pass {} first when you need a new object.

Underscore
var original = { a: 1 };
var copy = _.extendOwn({}, original, { b: 2 });

copy;
// → { a: 1, b: 2 }

original;
// → { a: 1 }   // unchanged
Try It Yourself

How It Works

  1. Empty dest. {} is the object that gets mutated.
  2. Copy. Own keys from original and { b: 2 } land on it.
  3. original. Never passed as destination — stays { a: 1 }.
  4. Pattern. Prefer this when mutation would surprise callers.

Browser & Runtime Support

_.extendOwn / _.assign 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.

✓ Stable · Underscore 1.x

_.extendOwn()

Available in [email protected] (UMD / ESM). Works in evergreen browsers and current Node LTS when Underscore is loaded.

100% With Underscore 1.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
_.extendOwn Underscore 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]). Native Object.assign is similar for own props in modern engines.

Frequently Asked Questions

_.extendOwn(destination, *sources) copies only the own enumerable properties from one or more sources into the destination and returns it. Inherited prototype properties are ignored.
_.assign is an alias for _.extendOwn — the same function. The name mirrors native Object.assign, which also copies own enumerable properties only.
_.extend copies all enumerable properties, including inherited ones. _.extendOwn copies only own properties, skipping the prototype chain.
Yes. It changes destination in place and returns it. Use _.extendOwn({}, source) when you want a new object.
Shallow. Nested objects and arrays are copied by reference — destination and source share those nested values.
When you want to merge plain own data and skip anything inherited from a prototype — closer to Object.assign than to _.extend.

Next: _.pick()

Keep only the keys you need — a filtered shallow copy.

_.pick() 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.

10 people found this page helpful