Object.create() vs. constructor vs. object literal
JavaScript performance comparison
Preparation code
<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
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Object.create() using in-place property object |
|
pending… |
Object.create() using pre-defined property object |
|
pending… |
Constructor function |
|
pending… |
Object.create() using in-place prototype object |
|
pending… |
Object.create() using pre-defined prototype object |
|
pending… |
Crockford method using in-place prototype object |
|
pending… |
Crockford method using pre-defined prototype object |
|
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
- Revision 7: published by Jeremy Ashkenas
- Revision 9: published
- Revision 10: published
- Revision 11: published by Gavin Huang
- Revision 12: published by Joseph Gentle
- Revision 15: published
- Revision 31: published
- Revision 32: published by Forrest L Norvell
- Revision 34: published
- Revision 35: published
- Revision 37: published
- Revision 38: published
- Revision 39: published
- Revision 40: published by ju1ius
- Revision 42: published by crazy2be
- Revision 43: published by Quentin Brooks
- Revision 44: published by Quentin Brooks
- Revision 46: published
- Revision 47: published by Dave
- Revision 49: published
- Revision 50: published
- Revision 52: published
- Revision 53: published
- Revision 54: published by Andrew F
- Revision 55: published
- Revision 58: published by ramesaliyev
- Revision 59: published
- Revision 60: published
- Revision 72: published
- Revision 77: published by test
- Revision 78: published
- Revision 79: published by wenbing
0 comments