title: javascript - Replace an object with another one
body: <pre><code>var obj1 = New MyObject('Object 1');
  var obj2 = New MyObject('Object 2');
  
  var foo = { anObject : obj1 };
  
  foo.anObject = obj2;
  console.log(obj1.name);
  </code></pre>
  
  <p>Naturally, <code>obj1</code> didn't changed. But how to replace <code>obj1</code> by <code>obj2</code> in the whole script assuming I can only access <code>foo</code> ?</p>