title: Why array.indexOf(undefined) doesn't work if array is sparse
body: <p>I'm new at JavaScript and there is one thing that bothers me. I have got a very simple code: </p>
  
  <pre><code>var a = [];
  a[1] = 1;
  
  i = typeof(a[0]);
  index = a.indexOf(undefined);
  len = a.length;
  
  console.log(a);
  console.log("\n" + len);
  console.log("\n" + i);
  console.log("\n" + index);
  </code></pre>
  
  <p>My question is: Why indexOf returns -1, instead of 0. I know that this method compare by ===, but I used as a parameter keyword <em>undefined</em>. If I change method parameter to "undefined" it also doesn't work (but this for me it's obvious). Can someone explain me this and tell what is the simpliest way to find undefined value in array? </p>