title: JavaScript array of pointers like in C++
body: <p>I'm faced with a situation in JavaScript when I need to update an object via its pointer similar to С++ array of pointers to objects<br><br>
  Example code for my issue:
  <code></p>
  
  
  
  <pre class="lang-js prettyprint-override"><code>var foo = new Array();
  var bar = function(){ 
      this.test = 1;
      foo.push(this); // push an object (or a copy of object?) but not pointer
  };
  var barInst = new bar(); // create new instance
  // foo[0].test equals 1
  barInst.test = 2;
  // now barInst.test equals 2 but
  // foo[0].test still equals 1 but 2 is needed
  </code></pre>
  
  <p></code></p>
  
  <p>So, how can I solve this? Should I use a callback or something like this or there is an easy way to help me to avoid copying the object instead pushing the raw pointer into an array?</p>