title: Why does Object.assign behave differently from regular references?
body: <p>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.</p>
  <p>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?</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>// 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</code></pre>
  </div>
  </div>
  </p>