delete vs new object (v42)

Revision 42 of this benchmark created on


Preparation HTML

<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';
    }
  };

</script>

Setup

var o = {};
    for (var x in template) {
      o[x] = template[x];
    }

Test runner

Ready to run.

Testing in
TestOps/sec
Delete properties
for (var key in o) {
  if (key < 'n')
    delete o[key];
}
ready
Copy object
var o2 = {};
for (var key in o) {
  if (key >= 'n')
    o2[key] = o[key];
}
ready

Revisions

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