Object.assign()

by dshilkret

JavaScript

'use strict'

let one = { a: 1, b: 2, c: 3};
let two = { b: 20, c: 30, d: 40 };

let three = Object.assign({}, one, two);

alert(JSON.stringify(three));

var x = { id: 1, name: "myObject" };
Object.assign(x, { id: 2, name: "myNewObject" });
alert(JSON.stringify(x));