title: Will the reference of an object passed into a function as a parameter change?
body: <p>Why is <code>a.y</code> undefined after I change the reference of <code>a</code> in the function?</p>
  
  <pre><code>var a = { x : 1 };
  a = { y : 2 };
  function _change(b) {
      b = { y : 3 };
      return b;
  }
  
  _change(a);
  document.write(a.y);   // undefined
  document.write(a.x);   //1
  </code></pre>
  
  <p>And the below code behaves differently</p>
  
  <pre><code>var a = {x:1};
  var b={y:1};
  b=a;
  a.x //undefined
  a.y //1
  </code></pre>
  
  <p>Why?</p>