splice vs slice when removing element (v7)

Revision 7 of this benchmark created by Dave on


Description

Check what's better to remove an element from an array

Preparation HTML

<script>
 
  var a = [], i = 1000;
  while (i > 0) {
    a.push({v:Math.random(), v1:i})
    i--;
  }
</script>

Test runner

Ready to run.

Testing in WebKit 537.36 / undefined
TestOps/sec
slice
var sliced = a.slice(0, 500).concat(a.slice(501))
ready
splice
var spliced = a.splice(500, 1);
ready

Revisions

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