push/pop vs unshift/shift (v43)

Revision 43 of this benchmark created on


Preparation HTML

<script>
  var arr = ['a', 'b', 'c', 'd'];
var e;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Push/Pop
e = arr.pop();
arr.push(e);
ready
Unshift/Shift
e = arr.shift();
arr.unshift(e);
ready
Unshift/Shift via Slice/Concat
e = arr[0];
arr = arr.slice(1);

arr = [e].concat(arr);
ready
Unshift/Shift via Splice/Concat
e = arr.splice(0, 1);
arr = [e].concat(arr);
ready
Splice/unshift
e = arr.splice(0, 1);
arr.unshift(e);
ready
Slice/unshift
e = arr[0];
arr = arr.slice(1);
arr.unshift(e);
ready

Revisions

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