title: How does `new Array(5).map()` work?
body: <p>I've recently discovered that mapping an uninitialised array doesn't seem to work as I would expect. With this code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function helloMap(value, index) {
      return "Hello " + index;
  }
  
  console.clear();
  
  var initialArray = Array.apply(null, new Array(5));
  
  console.log("Array initialised with apply:");
  console.log(initialArray);
  console.log(initialArray.map(helloMap));
  
  var normalArray = new Array(5);
  
  console.log("Array constructed normally");
  console.log(normalArray);
  console.log(normalArray.map(helloMap));</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.as-console-wrapper {
    max-height: 100% !important;
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>I get different results despite the first output for each array being <code>[undefined, undefined, undefined, undefined, undefined]</code>.</p>
  
  <p>The fact that I get different results implies that the <code>undefined</code> in these 2 arrays are in fact different. In the first I suspect that the array has 5 items in, each one is undefined. In the second the array is 5 items long but there is nothing, not even undefined in there...</p>
  
  <p>It's a bit confusing.</p>
  
  <p>Can someone explain it to me?</p>