This project is read-only.
1
Vote

Splice insert doesn't take start index into account

description

I've come across a case where splice doesn't work correctly.
myArray = [0, 1, 2];
// myArray.join() returns "0,1,2"

myArray.splice(1, 0, -1);
// I expect myArray.join() to return "0,-1,1,2" but it returns "-1,1,1,2"
I fixed it in my copy by changing the last loop.
from this:
            for (int k = 0; k < items.Count; k++)
                target[k.ToString()] = items[k];
to this:
            for (int k = actualStart; k < items.Count + actualStart; k++)
                target[k.ToString()] = items[k - actualStart];
I wonder if this breaks any other existing test cases, it doesn't do on mine

comments