Copy the values of all of the enumerable own properties from one or more source objects to a target object and returns the target object.
assign(target, ...source)
target
The target object to copy to.
source variadic
The source object from which to copy properties.
Properties in target with the same name as properties in the source object will be overwritten by the source object’s properties, in order of appearance (that is, the last source object will overwrite properties of the same name in previous arguments).
The target object.
let currencies = {USD: '$', EUR: '€'}
let oldCurrencies = {DEM: 'DM', FRF: 'F'}
Object.assign(currencies, oldCurrencies)
currencies
{USD: '$', EUR: '€', DEM: 'DM', FRF: 'F'}
let batteries = {AA: '1.5 V', AAA: '1.5 V', PP3: '9 V'}
let creditRatings = {AAA: 'prime', AA: 'high grade'}
let organizations = {AAA: 'American Automobile Association'}
Object.assign({}, batteries, creditRatings, organizations)
{ AA: "high grade", AAA: "American Automobile Association", PP3: "9 V" }