delete vs undefined vs null (v123)

Revision 123 of this benchmark created by Mike Lysikov on


Setup

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

Test runner

Ready to run.

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

Revisions

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