title: Filter performance on objects array
body: <p>If I have a an array of objects called <code>filteredList</code> and a function such as :</p>
  
  <pre><code>function    buildList(filteredList, p1, p2, p3) {
      var resultList = [];
  
      for (var i =0; i &lt; filteredList.length; i++) {
          if (filteredList[i].type === 'global' &amp;&amp; filteredList[i].p1 === p1 &amp;&amp; filteredList[i].p2 === p2 &amp;&amp; filteredList[i].p3 === p3)
              resultList.push(filteredList[i]);
      }
  
      return resultList;
  }
  </code></pre>
  
  <p>What would be the performance difference if instead of looping through my array like I do, I would do something like : <code>filteredList.filter(rebuildList)</code></p>
  
  <p><code>rebuildList</code> being a function checking the same conditions than <code>buildList</code></p>
  
  <p>Would it do the same ? (Looping through each element)</p>
  
  <p>Can you think of a more optimized and efficient way to do it ? I'm calling a function like <code>buildList</code> many times in my project and it consumes a great amount of time.</p>