title: Why does Array.apply(null, [args]) act inconsistently when dealing with sparse arrays?
body: <p>I recently discovered the following <a href="https://stackoverflow.com/a/13735425/1139652">snippet of code on SO</a> to aid in quickly populating an array with default values:</p>
  
  <pre><code>Array.apply(null, new Array(3)).map(function() {return 0;});
  </code></pre>
  
  <p>Given the behavior of the Array constructor and the apply method, the above snippet can also be rewritten as such:</p>
  
  <pre><code>Array.apply(null, [undefined, undefined, undefined]).map(function() {return 0;});
  </code></pre>
  
  <p>This technique is also useful when dealing with sparse arrays that you wish to populate with default values:</p>
  
  <pre><code>var sparseArr = [3,,,4,1,,],
      denseArr = Array.apply(null, sparseArr).map(function(e) {
        return e === undefined ? 0 : e;
      });
  
  // denseArr = [3,0,0,4,1,0]
  </code></pre>
  
  <p>However it is therein that two oddities arise:  </p>
  
  <ol>
  <li>If the final term of of <code>sparseArr</code> is undefined, that term  is not mapped in <code>denseArr</code></li>
  <li>If <code>sparseArr</code> contains only a single term (e.g. <code>sparseArr = [1]</code>) or a single term followed by a single trailing undefined term (e.g. <code>sparseArr = [1,]</code>), the resulting <code>denseArr</code> equals <code>[undefined x 1]</code></li>
  </ol>
  
  <p>Can anyone explain this behavior?</p>