Empty Array

JavaScript performance comparison

Revision 120 of this test case created by

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
for loop (forward)
var arr = [];
for (var i = 0; i < 10000; i++) { arr[i] = 0 }
for (var i = 0; i < arr.length; i++) {
  arr.splice(i, 1);
}
pending…
for loop (reversed)
var arr = [];
for (var i = 0; i < 10000; i++) { arr[i] = 0 }
for (var i = arr.length - 1; i >= 0; i--) {
  arr.splice(i, 1);
}
pending…
shift
var arr = [];
for (var i = 0; i < 10000; i++) { arr[i] = 0 }
while (arr.length > 0) {
  arr.shift();
}
pending…
pop
var arr = [];
for (var i = 0; i < 10000; i++) { arr[i] = 0 }
while (arr.length > 0) {
  arr.pop();
}
pending…
splice
var arr = [];
for (var i = 0; i < 10000; i++) { arr[i] = 0 }
arr.splice(0, arr.length);
pending…
length
var arr = [];
for (var i = 0; i < 10000; i++) { arr[i] = 0 }
arr.length = 0;
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.

0 Comments