title: Filter list using javascript
body: <p>I have a set of data that is stored locally and I use to filter the list using text input from the user. </p>
  
  <pre class="lang-js prettyprint-override"><code> var userData = {
       "product": [
            { "name":"cannon",
              "type":"camera",
              "serialno":"c123",
              "stock":10,
              "img":"http://placehold.it/400x250/000/fff",
              "Description":"blablabla"
            },
            { "name":"cannon2",
              "type":"camera2",
              "serialno":"c124",
              "stock":1,
              "img":"http://placehold.it/400x250/fff/000",
              "Description":"blablabla"
            }
            ]                                
                     };
  
                  if (event.keyCode != 13){
                          var isFound = false;
                          for(var i=0;i&lt;userData.product.length;i++){                             
                              var strings = userData.product[i].name.split(" ");
                              for(var string in strings){ 
                                  if(strings[string].startsWith(data)){
                                      result += openTag +userData.product[i].name+closeTag;
                                      isFound=true;
                                      break;
                                  }
                              }                           
                          }
  
                          if(!isFound){
                              result = openTag + "No Result Found" +closeTag;
                              console.log(result);                    
                          }
                  }
  </code></pre>
  
  
  
  <p>Here i archive the filter with using loop but i just want to know which is best way to filter out the list.</p>