delete vs undefined vs null (v22)

Revision 22 of this benchmark created by Thorsten Lorenz 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
Set to void 0
o.p = void 0;
ready

Revisions

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