Object.create vs Crockford vs Jorge vs Constructor (v50)

Revision 50 of this benchmark created by Marc Nieper-Wißkirchen on


Preparation HTML

<script>
  var sharedPrototype = {
   one: function() {
    return 1;
   },
   two: function() {
    return 2;
   },
   three: function() {
    return 3;
   }
  };
  
  var crockfordCreate = function(proto) {
   var f = function() {};
   f.prototype = proto;
   return new f();
  };
  
  var jorgeCreate = (function() {
   var f = function() {};
   return function(proto) {
    f.prototype = proto;
    return new f();
   };
  })();

  var objectCreate = Object.create;
  
  var Constructor = function() {};
  Constructor.prototype = sharedPrototype;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Object.create()
var instance = Object.create(sharedPrototype);
ready
Crockford Create
var instance = crockfordCreate(sharedPrototype);
ready
Jorge Create
var instance = jorgeCreate(sharedPrototype);
ready
Constructor
var instance = new Constructor;
ready
objectCreate
var instance = objectCreate(sharedPrototype);
ready

Revisions

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