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

JavaScript performance comparison

Revision 91 of this test case created

Preparation code

<script>
function Obj() {
}
 
ObjProto = Obj.prototype = {
    method1: function () { },
    method2: function () { },
    method3: function () { },
    method4: function () { },
    method5: function () { },
    method6: function () { },
    method7: function () { },
    method8: function () { },
    method9: function () { },
    method10: function () { }
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Object.create()
o = Object.create(ObjProto);
pending…
Constructor function
o = new Obj();
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:

0 comments

Add a comment