delete vs undefined vs null

JavaScript performance comparison

Revision 12 of this test case created by

Preparation code

<script>
  'use strict';
  var template = {
    a: 1,
    b: 2,
    c: 3,
    d: 4,
    e: 5,
    f: 6,
    g: 7,
    h: 8,
    i: 9,
    j: '10',
    k: 11,
    l: '12',
    m: function() {
      return 13;
    },
    n: 14,
    o: function() {
      return '15';
    }
  };
  var dump, log = function() {
      dump = arguments;
      };
</script>
      
<script>
Benchmark.prototype.setup = function() {
  var o = {};
  for (var x in template) {
    o[x] = template[x];
  }

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Baseline (no modification)
log(o.j + o.l + o.o(), o.m());
pending…
Setting properties to null
o.a = null;
o.i = null;
o.d = null;
o.f = null;
log(o.j + o.l + o.o(), o.m());
pending…
Setting properties to undefined
o.a = undefined;
o.i = undefined;
o.d = undefined;
o.f = undefined;
log(o.j + o.l + o.o(), o.m());
pending…
Deleting properties
delete o.a;
delete o.i;
delete o.d;
delete o.f;
log(o.j + o.l + o.o(), o.m());
pending…

Compare results of other browsers

Revisions

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

0 Comments