Array#splice sparse array spec question.

# John-David Dalton (13 years ago)

Can someone confirm/reject that by spec (es5.github.com/#x15.4.4.12):

// sparse array ;D var a=[0]; a[2]=2;

// the resulting arrays length should be 1 and not 2 console.log(a.splice(0, 2).length);

I'm seeing 2 in latest Chrome/FF.

Thanks,

# Allen Wirfs-Brock (13 years ago)

This is a spec. bug. Immediately before line10 of the algorithm there should be a line that says:

     Call the [[Put]] internal method of A with arguments "length", actualDeleteCount, and true. 

The ES3 spec. has the equivalent of the above line. It was apparently inadvertently dropped in the ES5 spec.

Chrome's behavior (and also Firefox, I haven't checked others) matches the intended ES3 behavior.

I'll file a bug against the the ES5 spec.

Allen

Chrome is correct

# Allen Wirfs-Brock (13 years ago)