title: How do I get the indexOf an element using a criteria function
body: <p>I'd like to get the <code>indexOf</code> an object in an array, by using a criteria function.</p>
  
  <p><strong>attempt1:</strong> works, but is inefficient, as I have to iterate the array twice.</p>
  
  <p><strong>attempt2:</strong> doesn't work (obviously), but indicates what I'd like to achieve.</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>const dataSet = [{ name: "obj1" }, { name: "obj2" }, { name: "obj3" }, { name: "obj4" }, { name: "obj5" }]
  
  const attempt1 = dataSet.indexOf(dataSet.find(d =&gt; d.name === 'obj3'))
  
  const attempt2 = dataSet.indexOf(d =&gt; d.name === 'obj3')
  
  console.log(attempt1)
  console.log(attempt2)</code></pre>
  </div>
  </div>
  </p>