Array vs AppendText

JavaScript performance comparison

Test case created by Patrick

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Using an array
var blankArray = [];

for (x = 0; x < 16; x++) {

  blankArray.push("s" + x);
}

document.write(blankArray.toString);
pending…
Using a string
var blankString = "";

for (x = 0; x < 16; x++) {

  if (x == 15) {
    blankString += "s" + x;
  } else {
    blankString += "s" + x + ",";
  }

}
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