title: How to remove some items by iterating over the array of objects?
body: <p>I want to iterate through the array of object and remove some of them based on some condition.</p>
  
  <p>I used splice for removing the items to preserve an orderly count of items.</p>
  
  <p>Then each time the item removed I would decrease the count.</p>
  
  <p>But for some reason it never works:</p>
  
  <pre><code>var arr=[{img:1},{img:2},{img:3},{img:4}];
  for (var i=0, count= arr.length; i &lt; count; ) {
      if ( this.arr[i].img==3 ) {
          this.arr.splice(i,1);
          count--;
      }else  i++
  };
  alert(JSON.stringify(arr));
  </code></pre>
  
  <p>​
  ...any ideas?</p>