Object delete vs. array splice vs. array delete

Benchmark created on


Description

Is it faster to remove an item from an array (and thus allow the indices to be renumbered) or delete a property from an object. Also, checking deletion from array, but this does not renumber the indices so may not be preferable.

Preparation HTML

<script>
  var someArr = [4, 5, 6];
  var someObj = {
   a: 4,
   b: 5,
   c: 6
  };
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Splice
someArr.splice(1, 1);
ready
Object Delete
delete someObj.b;
ready
Array Delete
delete someArr[1];
ready
Object sub-script Delete
delete someObj['b'];
ready

Revisions

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