Iterate Array Backwards and Splice

2019-01-14

var a = [1, 2, 3, 4, 5];
for (i = a.length - 1; i > -1; i--) {
    console.log(a, a[i]);
    a.splice(i, 1); 
}
console.log(a);