4.17.11
3.10.1
2.4.2
1.3.1
_.assign(object, [sources])
Assigns own enumerable string keyed properties of source objects to the
destination object. Source objects are applied from left to right.
Subsequent sources overwrite property assignments of previous sources.
Note: This method mutates object
and is loosely based on
Object.assign
.
Since
0.10.0
Arguments
argument
object
[sources]
type
Object
...Object
description
The destination object.
The source objects.
Returns
(array)
Example
function Foo() {
this.a = 1;
}
function Bar() {
this.c = 3;
}
Foo.prototype.b = 2;
Bar.prototype.d = 4;
_.assign(
{ a: 0 },
new Foo(),
new Bar()
);
// => { 'a': 1, 'c': 3 }
function Foo() {
this.a = 1;
}
function Bar() {
this.c = 3;
}
Foo.prototype.b = 2;
Bar.prototype.d = 4;
_.assign({ a: 0 }, new Foo(), new Bar());
// => { 'a': 1, 'c': 3 }