Object.create() vs. constructor vs. object literal (v11)

Revision 11 of this benchmark created by Gavin Huang on


Preparation HTML

<script>
  Obj = function() {
   this.p = 1;
  };
  
  propObj = {
   p: {
    value: 1
   }
  };
  
  protoObj = {p: 1};
  
  function object(o) {
      function F() {}
      F.prototype = o;
      return new F();
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Object.create() using in-place property object
o = Object.create(Object.prototype, {
 p: {
  value: 1
 }
});
ready
Object.create() using pre-defined property object
o = Object.create(Object.prototype, propObj);
ready
Constructor function
o = new Obj();
ready
Object.create() using in-place prototype object
o = Object.create({p: 1});
ready
Object.create() using pre-defined prototype object
o = Object.create(protoObj);
ready
Crockford method using in-place prototype object
o = object({p: 1});
ready
Crockford method using pre-defined prototype object
o = object(protoObj);
ready

Revisions

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