title: What's the best way to query an array in javascript to get just the items from it I want?
body: <p>I have an array like this (with just over 3000 objects instead of the 3 here):</p>
  
  <pre><code>items = [{name:'charlie', age:'16'}, {name:'ben', age:'18'}, {name:'steve', age:'18'}]
  </code></pre>
  
  <p>What's the best way to return an array with just the objects of people who are 18? So I want:</p>
  
  <pre><code>items = [{name:'ben', age:'18'}, {name:'steve', age:'18'}]
  </code></pre>
  
  <p>The best I can think of is this (using jQuery):</p>
  
  <pre><code>newArray = []
  $.each(items, function(index, item) {
      if(item.age=='18') {
          newArray.push(item)
      }
  })
  </code></pre>
  
  <p>Considering that there's 3000 thousand objects, and also that I'll be doing that comparison up to fifty times in one go, that's a lot of looping. Is there a better way?</p>