Object.assign () method is used to enumerate all the attribute values are copied from one or more source object to the target object. It will return to the target object.
grammar:
Object.assign(target, ...sources)
:( parameter is to copy the sources of the things to target where to save up)
If the same name attribute, between the front cover behind the target object and the source object.
-
target
target. -
sources
Source object (which may be several)
return value:
target.
Copy an object
const obj = { a: 1 }; const copy = Object.assign({}, obj); console.log(copy); // { a: 1 }