I want to mix two objects in JavaScript:
let a = {x: 1, y: 2, z:3};
let b = {x:10, y: 20};
let c = Object.assign(a, b);
This gives the correct value for c
:
Object { x: 10, y: 20, z: 3 }
But now a
has been modified too!
Object { x: 10, y: 20, z: 3 }
Is there a way to assign a
onto b
into a new object?