Object.assign()

object.assign()

by Rich Costello

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);

console.log(three);

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

console.log(x);