Object.create vs Crockford vs Constructor
JavaScript performance comparison
Info
Wondering how much of a difference hoisting f out of crockfordCreate will make.
Preparation code
<script>
var sharedPrototype = {
one: function() {
return 1;
},
two: function() {
return 2;
},
three: function() {
return 3;
}
};
function F() {}
var crockfordCreate = function(proto) {
F.prototype = proto;
return new F();
};
var Constructor = function() {};
Constructor.prototype = sharedPrototype;
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Object.create() |
|
pending… |
Crockford Create |
|
pending… |
Constructor |
|
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:
- Revision 1: published by Jeremy Ashkenas
- Revision 9: published
- Revision 10: published by Jeremy Ashkenas
- Revision 11: published
- Revision 12: published by Vjeux
- Revision 15: published
- Revision 16: published by Peter Michaux
- Revision 17: published by Peter Michaux
- Revision 18: published by Kevin Gadd
- Revision 19: published by Brian Cavalier
- Revision 20: published by Rob Friesel
- Revision 21: published
- Revision 22: published by Mark Bradley
- Revision 23: published
- Revision 24: published
- Revision 25: published
- Revision 26: published
- Revision 27: published by Scott Sauyet
- Revision 29: published
- Revision 30: published by Leo Cavalcante
- Revision 31: published
0 comments