Concatenation vs Array Join

JavaScript performance comparison

Revision 13 of this test case created by Rita

Preparation code

<script>
  var str, str1, i, j;
</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
for (i = 0; i < 10; i++) {
 str += 'a';
}
pending…
Array.prototype.join
var tmp = [];
for (j = 0; j < 10; j++) {
 tmp.push('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:

1 comment

Jesús commented :

See also http://jsperf.com/append-string-vs-join-array . Revision 5 has more ways to do that

Add a comment