update
Updates the values of an object match the values of an other object.
.update(target, source)
Updates the values (and properties if map-like) of target
to match the values of source
.
Properties of target
that are not on source
will be removed. This does
not recursively update. For that, use updateDeep.
For map-like objects, every enumerable property on target
is copied:
var target = {name: {first: "Justin"}, age: 34};
var source = {name: {last: "Meyer"}};
var result = canReflect.update(target, source);
target //-> {name: {last: "Meyer"}}
With Arrays all items of the source will be replaced with the new items.
var target = ["a","b","c"];
var source = ["A","B"];
canReflect.update(target, source);
target //-> ["A","B"]
Parameters
- target
{Object}
:The value that will be updated with
source
's values. - source
{Object}
:A source of values to copy to
target
.
Returns
{Object}
:
The target.