delete vs undefined vs null (v40)

Revision 40 of this benchmark created on


Description

The delete operator removes a property entirely. Setting a property to undefined removes the value. Setting a property to null changes the value to the null value.

Technically they are not equivalent, but in practice they are often used to mean the same thing: that a property is unset.

Test runner

Ready to run.

Testing in
TestOps/sec
delete object.property
delete o.p;
ready
delete object["property"]
var o = {
  p: 0
};
delete o["p"];
ready
object.property = undefined
var o = {
  p: 0
};
o.p = undefined;
ready
object["property"] = undefined
var o = {
  p: 0
};
o["p"] = undefined;
ready
object.property = null
var o = {
  p: 0
};
o.p = null;
ready
object["property"] = null
var o = {
  p: 0
};
o["p"] = null;
ready
object["property"] = void null
var o = {
  p: 0
};
o["p"] = void null;
ready

Revisions

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