deep-assign
deepAssign(target, [ ... sources ])
Assign properties from a source object to a target object, deeply copying properties that are objects or arrays.
var deepAssign = require("can-util/js/deep-assign/deep-assign");
var dest = deepAssign({}, {
obj: {
foo: "bar"
}
}, {
arr: [{ hello: "world" }]
});
console.log(dest.obj.foo); // -> "bar"
Parameters
- target
{Object}
:The target object who's properties will be assigned from the source objects.
- source
{Object}
: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).