title: How to tell between undefined array elements and empty slots?
body: <p>Suppose I am a user script developer and I don't have control over the on-page javascript. The page creates arrays with random lengths, filling them with random values (including falsy ones, such as <code>undefined</code>). Not every element has to be assigned a value, so there may be empty slots.</p>
  
  <p>A simplified example (Firefox console):</p>
  
  <pre><code>var arr = new Array(3);
  arr[0] = null;
  arr[1] = undefined;
  console.log(arr);               \\ Array [ null, undefined, &lt;1 empty slot&gt; ]
  console.log(arr[1]);            \\ undefined
  console.log(arr[2]);            \\ undefined
  console.log(arr[1] === arr[2]); \\ true
  console.log(typeof arr[1]);     \\ undefined
  console.log(typeof arr[2]);     \\ undefined
  </code></pre>
  
  <p>As we can see, Firefox displays <code>undefined</code> and empty slots differently, whereas for javascript they seem to be identical.</p>
  
  <p>Now suppose I want to clean such an array, removing all empty slots but leaving <code>undefined</code> elements intact. How do I do that?</p>