assign
Assign one objects values to another
.assign(target, source)
Copies the values (and properties if map-like) from source
onto target
.
For map-like objects, every enumerable property on target
is copied:
var target = {};
var source = {key : "value"};
var restult = canReflect.assign(target, source);
result === target //-> true
target //-> {key : "value"}
For Arrays, enumerated values are copied over, but the length of the array will not be trunkated. Use update for trunkating.
var target = ["a","b","c"];
var source = ["A","B"];
canReflect.assign(target, source);
target //-> ["A","B","c"]
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.