title: What's difference between find() and indexOf() methods for array
body: <p><a href="https://stackoverflow.com/questions/143847/best-way-to-find-if-an-item-is-in-a-javascript-array">Best way to find if an item is in a JavaScript array?</a></p>
  
  <pre><code>var array = [2, 5, 9];
  array.indexOf(2);     // 0
  array.indexOf(7);     // -1
  
  
  let found = array.find(x =&gt; x === 5 );
  console.log(found); //5
  
  found = array.find(x =&gt; x === 51 );
  console.log(found); //undefined
  </code></pre>
  
  <p>What method use to detect value in array ?</p>
  
  <p><code>array.indexOf(val) !== -1</code> or </p>
  
  <pre><code>typeof array.find(x =&gt; x === val ) !== 'undefined';
  </code></pre>