pushing javascript objects to arrays
<p>I have a loop goes through an array of objects MyArrayOfObjects and then pushes the objects to a new array like this:</p>

<pre><code>var NewArray = new Array();

for (i = 0; i &lt; MyArrayOfObjects.length; i++) {

  TempObject = null;
  TempObject = new Object();

 // I have logic that copies certain properties but not others
 // but overall it looks like this:

  TempObject.prop1 = MyArrayOfObjects[i].prop1;
  TempObject.prop2 = MyArrayOfObjects[i].prop2;

  NewArray.push(TempObject);
}
</code></pre>

<p>As I loop through MyArrayOfObjects, I clear the TempObject and create a new one each time. Does NewArray contain the objects that I'm copying or just a reference to the objects copied and that then become deleted as the loop iterates?</p>

<p>Thanks.</p>
