shift() vs splice() vs destructuring (v3)

Revision 3 of this benchmark created on


Setup

let head;
let arr = Array.from({
    length: 10_000
}, (_, index) => index);

Test runner

Ready to run.

Testing in
TestOps/sec
shift()
while (arr.length) {
  head = arr.shift();
}
ready
splice()
while (arr.length) {
  [head] = arr.splice(0, 1);
}
ready
destructuring
while (arr.length) {
	[head, ...arr] = arr;
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.