title: How to limit for 10 results the array.filter?
body: <p>I have big array, I want to make an autocomplete search, but I want to display only 10 results, so stop iterating through the array by the time there were found 10 results. I have made this:</p>
  
  <pre><code>let items = array.filter(r =&gt; r.indexOf(term)!=-1);
  console.log(items.length) // lots of items, need to be limited to 10
  </code></pre>
  
  <p>It works but I don't know how to stop the <code>array.filter</code> by the time it reaches the desired limit.</p>