Javascript Object Pushed into Array
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/728360/copying-an-object-in-javascript">Copying an Object in Javascript</a>  </p>
</blockquote>



<p>I have this code:</p>

<pre><code>var temp = [];
var obj = {name:"1"};
temp.push(obj);
obj.name = "2";
temp.push(obj);
</code></pre>

<p>What I'm expecting to be true:</p>

<pre><code>temp[0].name == "1" &amp;&amp; temp[1].name == "2";
</code></pre>

<p>What actually happens:</p>

<pre><code>temp[0].name == "2" &amp;&amp; temp[1].name == "2";
</code></pre>

<p>Can someone explain to me why this happens and how I can get what I'm expecting?</p>
