Why is filling a new Array so much faster with a while loop?
<p>I was considering ways to create arrays containing a default value using native methods and ended up with</p>

<pre><code>function pushMap(length, fill){
    var a = [], b = [];
    a.length = length;
    b.push.apply(b,a);
    return b.map(function(){return fill;});
}
</code></pre>

<p>Expecting it to be <strong>2</strong> or <strong>3</strong> times slower than a while loop, as the native methods have to loop twice whereas while loops only once, so I compared it on <a href="http://jsperf.com/make-filled-array"><strong>jsperf</strong></a> against</p>

<pre><code>function whileLengthNew(len, val) {
    var rv = new Array(len);
    while (--len &gt;= 0) {
        rv[len] = val;
    }
    return rv;
}
</code></pre>

<p>and it is actually <strong>18</strong> to <strong>27</strong> times slower (tested with Google Chrome on Ubuntu, browsers/OSs welcome).</p>

<p>What is happening that causes such a big difference?</p>
