Empty Array

JavaScript performance comparison

Revision 118 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
splice
var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
arr.splice(0, arr.length);
pending…
pop
var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
while (arr.length > 0) {
  arr.pop();
}
pending…
shift
var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
while (arr.length > 0) {
  arr.shift();
}
pending…
new
var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
arr = []
pending…
for loop (reversed)
var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
for (var i = arr.length - 1; i >= 0; i--) {
  arr.splice(i, 1);
}
pending…
for loop (forward)
var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
for (var i = 0; i < arr.length; i++) {
  arr.splice(i, 1);
}
pending…
length
var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
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