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.
As stated in this post the javascript way of doing this would be:
var i = array.length
while (i--) {
...
if (...) {
array.splice(i, 1);
}
}
Unfortunately, the typescript for (let item of array) {}
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.