« Bugzilla Issues Index

#1566 — ArrayBuffer.prototype.slice should return zero-length ArrayBuffer if final < first

To wit:
In Firefox and Chrome,
new ArrayBuffer(10).slice(2,1).byteLength
is 0.

The current spec in prescribes, in step 11 "Let newLen be final-first", and then in step 15 call constructor on newLen, which throws for negative length.

However primo, current implementations return 0-length ArrayBuffer in that case, and secundo, the behavior of slice should be consistent with TypedArray.prototype.subarray spec, which prescribes returns 0-length TypedArray.

fixed in rev 16 editor's draft

fixed in rev16 draft. July 15, 2013