title: JavaScript - pass objects by reference
body: <blockquote>
  <p><strong>Possible Duplicate:</strong> <br/>
  <a href="https://stackoverflow.com/questions/5865094/how-can-i-store-reference-to-a-variable-within-an-array">How can I store reference to a variable within an array?</a></p>
  </blockquote>
  
  <p>Consider the following code:</p>
  <pre><code>var a = 'cat';
  var b = 'elephant';
  var myArray = [a,b];
  
  a = 'bear';
  </code></pre>
  <p>myArray[0] will still return 'cat'. Is there a way to store references in the array instead of clones, so that myArray[0] will return 'bear'?</p>