title: In an array of objects, fastest way to find the index of an object whose attributes match a search
body: <p>I've been surfing around a little trying to find an efficient way to do this, but have gotten nowhere. I have an array of objects that looks like this:</p>
  <pre><code>array[i].id = some number;
  array[i].name = some name;
  </code></pre>
  <p>What I want to do is to find the INDEXES of the objects where id is equal to, for example, one of 0,1,2,3 or 4.
  I suppose I could just do something like :</p>
  <pre><code>var indexes = [];
  for(i=0; i&lt;array.length; i++) {
    (array[i].id === 0) ? { indexes[0] = i }
    (array[i].id === 1) ? { indexes[1] = i }
    (array[i].id === 2) ? { indexes[2] = i }
    (array[i].id === 3) ? { indexes[3] = i }
    (array[i].id === 4) ? { indexes[4] = i }
  }
  </code></pre>
  <p>While this would work, it looks to be quite expensive and slow (not to mention ugly), especially if array.length could be large. Any ideas on how to spruce this up a bit? I thought of using array.indexOf somehow but I don't see how to force the syntax. This</p>
  <pre><code>array.indexOf(this.id === 0);
  </code></pre>
  <p>for example, returns undefined, as it probably should.</p>