How did the value of Object Array in javascript be operated?
<p>I feel puzzled when I rethink of these two functions:</p>

<p>The first one goes like this:</p>

<blockquote>
  <p><code>var test = [1,2,3];</code><br>
  <code>var ele = test[0];</code><br>
  <code>ele= 2;</code><br>
  <code>alert(test[0])</code>;</p>
</blockquote>

<p>The result is 1. I think this is obvious. But when I meet this:</p>

<blockquote>
  <p><code>var test = [{id:1},{},{}];</code><br>
  <code>var ele = test[0];</code><br>
  <code>ele.id = 2;</code><br>
  <code>alert(test[0].id);</code><br></p>
</blockquote>

<p>The result turns to be 2<br>
So could anyone tell me that how the javascript work when it happens like this in the object array?</p>
