Concatenation vs Array Join

JavaScript performance comparison

Revision 21 of this test case created

Preparation code

<script>
  var str, str1, i, j, tmp ;
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Concatenation
str = '';
for (i = 0; i < 1000; i++) {
 str += 'a';
}
pending…
Array.prototype.join
tmp = [];
for (j = 0; j < 1000; j++) {
 tmp.push('a');
}
//str2 = tmp.join('');
pending…
Predefined Array Length
tmp = new Array(1000);
for (j = 0; j < 1000; j++) {
 tmp[j] = 'a';
}
//str2 = tmp.join('');
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:

0 comments

Add a comment