Replacing an element in an object array
<p>I want to replace the entire object in an array.</p>

<p><a href="http://jsfiddle.net/CWSbJ/" rel="nofollow">http://jsfiddle.net/CWSbJ/</a></p>

<pre><code>var array = [ {name: "name1" }, { name: "name2" } ];
var element = array[0];
element = {name: "name3"};
alert(array[0].name);
</code></pre>

<p>In this piece of code I would expect the output name3, why can't I replace an entire object in an array like this? And what is the good way to do this?</p>
