Object.create(null) vs. object literal

JavaScript performance comparison

Revision 119 of this test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var created = Object.create(null);
    var literal = {};
    var LOOP_ITERATIONS = 100000;
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Object.create
var foo;
for (var i = 0; i < LOOP_ITERATIONS; ++i)
  foo = Object.create(null);
pending…
literal
var foo;
for (var i = 0; i < LOOP_ITERATIONS; ++i)
  foo = {};
pending…
Object.create - populate
for (var i = 0; i < LOOP_ITERATIONS; ++i)
  created['foo' + i] = '' + i;
pending…
literal - populate
for (var i = 0; i < LOOP_ITERATIONS; ++i)
  literal['foo' + i] = '' + i;
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. Here’s a list of current revisions for this page:

0 comments

Add a comment