delete vs undefined vs null (v124)

Revision 124 of this benchmark created by Mike Lysikov on


Setup

function omit(source, keyToOmit) {
    const {[keyToOmit]: toRemove, ...rest} = source;
    return rest;
  }
  
  var o = {};

Test runner

Ready to run.

Testing in
TestOps/sec
omit(object, 'keyToOmit');
o.p = undefined;
omit(o, 'p');
ready
object.property = false
o.p = undefined;
o.p = false;
ready
delete object["property"]
o.p = undefined;
delete o["p"];
ready
object["property"] = false
o.p = undefined;
o["p"] = false;
ready
object.property = null
o.p = undefined;
o.p = null;
ready
object.property = undefined
o.p = undefined;
o.p = undefined;
ready
delete object.property
o.p = undefined;
delete o.p;
ready

Revisions

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