splice vs slice

Benchmark created by DannyC on


Description

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

Preparation HTML

<script>
  var a;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
slice
a = [1, 2, 3, 4, 5, 6, 7];
a = a.slice(0, 3).concat(a.slice(4))
ready
splice
a = [1, 2, 3, 4, 5, 6, 7];
a.splice(3, 1);
ready

Revisions

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