title: Does JavaScript have an indexOf(lambda) or similar?
body: <p>I want to return the index of the first element satisfying a unary predicate. </p>
  
  <p>Example: </p>
  
  <pre><code>[1,2,3,4,5,6,7].indexOf((x) =&gt; x % 3 === 0) // returns 2
  </code></pre>
  
  <p>Is there such a function? The alternative I was going to use was</p>
  
  <pre><code>[1,2,3,4,5,6,7].reduce((retval,curelem,idx) =&gt; 
  {
     if(curelem % 3 === 0 &amp;&amp; retval === undefined)
         retval = idx; 
     return retval;
  }, undefined);
  </code></pre>
  
  <p>but of course that would be less efficient since it doesn't stop iterating through the array after it has found the element.</p>