title: Typescript way to slice elements from array while looping over it
body: <p>What is the typescript way to slice elements from an array while looping over all its elements? Obviously, I want to take into account that the array is re-indexed at every splice.</p>
  
  <p>As stated in <a href="https://stackoverflow.com/questions/9882284/looping-through-array-and-removing-items-without-breaking-for-loop">this post</a> the javascript way of doing this would be:</p>
  
  <pre><code>var i = array.length
  while (i--) {
      ...
      if (...) { 
          array.splice(i, 1);
      } 
  }
  </code></pre>
  
  <p>Unfortunately, the typescript <code>for (let item of array) {}</code> loops from 0 to array.length-1 instead of the other way around like the js function above. Splicing an element in this loop would result in one item being skipped.</p>