Like _.assign, but iterates over own and inherited enumerable source properties. Alias: _.extend. Part of Lodash Object since 4.0.0 (stable — not deprecated).
Pass the object and path or keys shown below. Check whether the helper mutates or returns a new object.
Syntax
Call _.assignIn. Start with this line.
Lodash
_.assignIn(object, ...sources)
Call
What it does
_.assignIn(object, ...sources)
Primary signature.
_.assignIn(object)
Work with an object’s keys, values, or paths.
Prefer import assignIn from "lodash/assignIn" when you want a smaller bundle.
Library declarations
Lodash
_.assignIn(object, ...sources)
Parameters
Parameter
Description
object
Required. Destination (mutated and returned)
...sources
Optional. Own + inherited enumerable string keys
Return Value
Return Value
Description
*
The mutated object
Lodash Examples
Example 1 — Official: Own + Inherited Keys
Prototype properties are copied along with own instance keys.
Lodash
function Foo() {
this.a = 1;
}
function Bar() {
this.c = 3;
}
Foo.prototype.b = 2;
Bar.prototype.d = 4;
_.assignIn({ 'a': 0 }, new Foo, new Bar);
// → { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
Identity. In the full build, they are the same function.
Style. Prefer assignIn in new code; extend is fine in older codebases.
Example 4 — Non-Mutating Pattern
Pass {} as the destination to leave sources untouched.
Lodash
function User() {
this.name = 'Ada';
}
User.prototype.role = 'admin';
var user = new User();
var copy = _.assignIn({}, user);
// → { name: 'Ada', role: 'admin' }
// user is unchanged
Same as assign. Only the key set (own vs inherited) differs.
Compatibility
Browser & Runtime Support
_.assignIn is a Lodash Object helper (available since 4.0.0, stable in 4.x; alias _.extend). It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash.
✓ Stable · Lodash 4.0.0+
_.assignIn()
Available in [email protected] full builds and the lodash/assignIn modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.
100%With Lodash 4.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
_.assignInLodash 4.0.0+
Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import assignIn from "lodash/assignIn" for smaller builds. Use _.assign when you only need own keys.
Frequently Asked Questions
_.assignIn(object, ...sources) copies own and inherited enumerable string-keyed properties from each source onto object, left to right. Later sources overwrite earlier keys. It returns the mutated object.
Yes. _.extend is the documented alias of _.assignIn. Same function, two names.
_.assign copies own keys only. _.assignIn also copies enumerable inherited keys from the prototype chain.
Yes. Use _.assignIn({}, a, b) when you want a new object.
No. It is shallow — nested objects and arrays are copied by reference. Use _.merge for recursive plain-object merges.
Use import assignIn from "lodash/assignIn" or require("lodash/assignIn"). Full build: import _ from "lodash" then _.assignIn or _.extend.