delete vs undefined vs null (v44)

Revision 44 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.

Setup

var o = {
      p: [1,2,3]
    };

Test runner

Ready to run.

Testing in
TestOps/sec
delete object.property
 delete o.p;
 o.p = [1,2,3];
ready
delete object["property"]
 delete o["p"];
 o.p = [1,2,3];
ready
object.property = false
 o.p = false;
 o.p = [1,2,3];
ready
object["property"] = false
 o["p"] = false;
 o.p = [1,2,3];
ready
object.property = null
 o.p = null;
 o.p = [1,2,3];
ready
object.property = undefined
 o.p = undefined;
 o.p = [1,2,3];
ready

Revisions

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