title: Remove items from array with splice in for loop
body: <p>I want to implement a kind of jQuery live search.
  But before sending the input to the server I'd like to remove all items in my array which have 3 or less characters (because in the german language, those words usually can be ignored in terms of searching)
  So <code>["this", "is", "a", "test"]</code> becomes <code>["this", "test"]</code></p>
  
  <pre><code>$(document).ready(function() {
  var timer, searchInput;
  $('#searchFAQ').keyup(function() {
      clearTimeout(timer);
      timer = setTimeout(function() {
          searchInput = $('#searchFAQ').val().match(/\w+/g);
          if(searchInput) {
              for (var elem in searchInput) {
                  if (searchInput[elem].length &lt; 4) {
                      //remove those entries
                      searchInput.splice(elem, 1);
                  }
              }
              $('#output').text(searchInput);
              //ajax call here
          }
      }, 500);
  });
  });
  </code></pre>
  
  <p>Now my problem is that not all items get removed in my for loop. 
  If I for example typ "this is a test" "is" gets removed, "a" stays.
  <a href="http://jsfiddle.net/4Wdp9/">JSFIDDLE</a></p>
  
  <p>I think the problem is the for loop because the indexes of the array change if I remove an item with splice, so it goes on with the "wrong" index.</p>
  
  <p>Perhaps anybody could help me out?</p>