can-util
Version:
Common utilities for CanJS projects
23 lines (17 loc) • 780 B
Markdown
-util/js/deep-assign/deep-assign deep-assign
can-util/js
`deepAssign(target, [ ... sources ])`
Assign properties from a source object to a target object, deeply copying properties that are objects or arrays.
```js
import deepAssign from "can-util/js/deep-assign/deep-assign";
const dest = deepAssign( {}, {
obj: {
foo: "bar"
}
}, {
arr: [ { hello: "world" } ]
} );
console.log( dest.obj.foo ); // -> "bar"
```
{Object} target The target object who's properties will be assigned from the source objects.
{...Object} source Source objects from which properties will be assigned to the `target` object. Sources will be copied deeply; meaning any object or array properties will be traversed and copied (like a clone).
{function} can