If I have a simple reference to an object as in the first example, the way I understand it is x.a and y.a point to the same address which holds the value 1. When I change the value at that address to 2, the value changes in both x and y.
But in the second example, I use Object.assign to create y. x and y are different references, but x.a and y.a both point to the same address. So why is it that when I change x.a, y.a is not changed in this case?
// simple reference
var x = {a:1};
var y = x;
console.log(x === y); // true
console.log(x.a === y.a) // true
x.a = 2;
console.log(y.a); // 2
console.log('end first example');
// same example but with Oject.assign
var x = {a:1};
var y = Object.assign({}, x);
console.log(x === y); // false
console.log(x.a === y.a); // true, x.a and y.a point to the same address
x.a = 2;
console.log(y.a); // 1, I was expecting this to be 2