array delete vs splice

Benchmark created on


Preparation HTML

<script>
  var item = 5;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
splice
var arr = [1,2,3,4,5,6,7,8,9,0];

var index = arr.indexOf(item);
if (index > -1) {
  arr.splice(index, 1);
};

var index = arr.indexOf(item);
if (index > -1) {
  arr.splice(index, 1);
};
ready
delete
var arr = [1,2,3,4,5,6,7,8,9,0];
delete arr[arr.indexOf(item)];
delete arr[arr.indexOf(item)];
ready

Revisions

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