i just confuse why splice in loop vs splice multi line have different result
example:
var list = ["0","1","2","3","4"]; var removeIndex = [0,2,4]; case 1:
for (var i = removeIndex.length -1; i >= 0; i--) list.splice(removeIndex[i],1); result: list -> [1,3]
case 2:
list.splice(0,1); list.splice(2,1); list.splice(4,1); result: list -> [1,2,4]
Does anyone know why?
#i get it, that loop backwards case1 not shift index like case2 i f**king stupid that code case1 i copy from somewhere and i don't realize it(i alway think the loop is forwards).
removeIndexis sorted that way).