pop vs slice vs shift (v5)

Revision 5 of this benchmark created by Douglas Bagnall on


Description

What is the fastest way to remove an element of an array.

Preparation HTML

<script>
  var l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
pop
l.pop();
 
ready
slice away end
l.slice(0,9);
ready
slice away start
l.slice(1);
ready
shift
l.shift();
ready

Revisions

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