String Append vs Array Push

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
String Append 1 char
str = "";
for(var i = 0; i <= 1000000; i++) {
  str += "f";
}
pending…
Array Push
array = [];
for(var i = 0; i <= 1000000; i++) {
  array.push("f");
}
array.join("");
pending…
String Append 10 chars
str = "";
for(var i = 0; i <= 100000; i++) {
  str += "0123456789";
}
pending…
Array Push 10 chars
array = [];
for(var i = 0; i <= 100000; i++) {
  array.push("0123456789");
}
array.join("");
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