push vs. array index

JavaScript performance comparison

Revision 2 of this 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
push
arr = [];
for (var i = 0; i < 100; i++) {
arr.push("test");
}
pending…
index
arr = [];
for (var i = 0; i < 100; i++) {
arr[i] = "test";
}
pending…
precreated index
arr = new Array(100);
for (var i = 0; i < 100; i++) {
arr[i] = "test";
}
pending…
push on precreated array
arr = new Array(100);
for (var i = 0; i < 100; i++) {
arr.push("test");
}
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:

1 comment

Sebastian commented :

Even faster...

Add a comment