literal vs new

JavaScript performance comparison

Test case created

Preparation code

<script>
  var o;
 
  if (!Object.create) {
    Object.create = function (o) {
      var f = function() { };
      f.prototype = o;
      return new f;
    }
  }
</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
new
o = new Array;
pending…
literal
o = [];
pending…
invoke
o = new Array();
pending…
create
o = Object.create(Array.prototype);
pending…
zero length
o = new Array(0);
pending…
without new
o = Array();
pending…
new with data
o = new Array("data");
pending…
array with data
o = Array("data");
pending…
literal with data
o = ["data"];
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