title: Why push method is significantly slower than putting values via array indices in Javascript
body: <p>I pretty don't understand why this test :</p>
  
  <p><a href="http://jsperf.com/push-method-vs-setting-via-key" rel="noreferrer">http://jsperf.com/push-method-vs-setting-via-key</a></p>
  
  <p>Shows that </p>
  
  <pre><code> a.push(Math.random());
  </code></pre>
  
  <p>is over ten times slower than </p>
  
  <pre><code> a[i] = Math.random();
  </code></pre>
  
  <p>Could you explain why this is the case ? What magic "push" do that make it so slow ? (or so slow compared to other valid method of doing that).</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>NOTE: The push test is biased. I increase size of the array every iteration! Read carefully accepted answer!</p>
  
  <p><img src="https://i.stack.imgur.com/SVd8B.png" alt="Benchmark results"></p>