@stdlib/object-assign-in
v0.1.1
Published
Copy enumerable own and inherited properties from one or more source objects to a target object.
Readme
assignIn
Copy enumerable own and inherited properties from one or more source objects to a target object.
Installation
npm install @stdlib/object-assign-inUsage
var assignIn = require( '@stdlib/object-assign-in' );assignIn( target, source1[, source2[,...,sourceN]] )
Copies enumerable own and inherited properties from one or more source objects to a target object.
function Foo() {
this.a = 'beep';
return this;
}
Foo.prototype.b = 'boop';
var x = {};
var y = new Foo();
var z = assignIn( x, y );
// returns { 'a': 'beep', 'b': 'boop' }
var bool = ( z === x );
// returns trueNotes
- If a property key is present in multiple sources, the property from the last source that defines the key prevails.
- The target object is mutated.
- Both string and symbol properties are copied.
Examples
var assignIn = require( '@stdlib/object-assign-in' );
function Foo() {
this.a = 1;
return this;
}
Foo.prototype.b = 2;
function Bar() {
this.c = 3;
return this;
}
Bar.prototype.d = 4;
var obj1 = new Foo();
var obj2 = new Bar();
var result = assignIn( {}, obj1, obj2 );
// returns { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2026. The Stdlib Authors.
