delete vs undefined vs null (v21)

Revision 21 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 = {
    };

Test runner

Ready to run.

Testing in
TestOps/sec
Delete
 delete o.p;
ready
Set to False
 o.p = false;
ready
Set to Zero
o.p = 0;
ready
Set to Null
 o.p = null;
ready
Set to Undefined
 o.p = undefined;
ready

Revisions

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