(Turned out it was a combined thing: a lazy console, and my old code where I started using arrays in function calls instead of a single number and thus handing over references that lead to modification of the actual and original array.)
I have problems with an array, that should have the value:
[0,1,2]
Now the problems. To start with the most obviously curious event, in a loop the two consecutively running lines:
anr = numberarray[i];
console.log('delete',anr,numberarray);
show
"delete" 2 Array [ -1, 1, 2 ]
"delete" 1 Array [ -1, 1, 2 ]
"delete" 0 Array [ -1, 1, 2 ]
Later on in the code the array is changed. (Actually the first number in the array was changed to -1.)
(Deleted part of my original text, as it's irrelevant for the actual question.)