Constructor vs Literal Array

JavaScript performance comparison

Test case created

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Constructor
var len = 10000;
var i = 0;
var arr;
var j = 0;
for (i; i < len; ++i) {
  j = 0;
  arr = new Array(i);
  for (j; j < i; ++j) {
    arr[j] = undefined;
  }
}
pending…
Literal
var len = 10000;
var i = 0;
var arr;
var j = 0;
for (i; i < len; ++i) {
  j = 0;
  arr = [];
  for (j; j < i; ++j) {
    arr.push(undefined);
  }
}
pending…

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

Compare results of other browsers

0 comments

Add a comment