Javascript pushing objects into array
<pre><code>var cb = [];
for (var i = 0; i &lt; 10; i++) {
    cb.push({
        'test': 'value'
    });
    console.log(cb);
};
</code></pre>

<p>I'm expecting to get: <code>[{test: value}, {test: value}, ... , {test: value}]</code></p>

<p>What I end up getting is the final result at every log statement:</p>

<blockquote>
  <p>[Object]</p>
  
  <p>[Object, Object]</p>
  
  <p>[Object, Object, Object]</p>
  
  <p>[Object, Object, Object, Object]</p>
  
  <p>[Object, Object, Object, Object, Object]</p>
  
  <p>[Object, Object, Object, Object, Object]</p>
  
  <p>[Object, Object, Object, Object, Object, Object]</p>
  
  <p>..........</p>
</blockquote>

<p>When I expand any of those arrays they all have the same result.
For example, the first array contains: </p>

<pre><code>[{test: value}, {test: value}, ... , {test: value}] 
</code></pre>

<p>which is the final value, shouldn't it just have 1 object?
The final result is what I expect, but I'm just confused about why after the first push the array has 10 elements.
Can someone please explain what's going on? </p>