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

Revision 46 of this benchmark created on


Preparation HTML

<script>
  Obj = function() {
   this.p = 1;
  }
  
  propObj = {
   p: {
    value: 1
   }
  };

var pObj=function(){}
pObj.prototype.p=1
</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 literal
o = {
 p: 1
};
ready
Object with prototype defined property
o = new pObj();
ready

Revisions

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