Concatenation vs Array Join (v25)

Revision 25 of this benchmark created by geometry9 on


Preparation HTML

<script>
  var str, str1, str3, i, j, x;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Concatenation
for (i = 0; i < 1000; i++) {
 str += 'a';
}
ready
Array.prototype.join
var tmp = [];
for (j = 0; j < 1000; j++) {
 tmp.push('a');
}
str2 = tmp.join('');
ready
Array.prototype.join
var tmp2 = [];
for (x = 0; x < 1000; x++) {
        tmp2[x] = "a";
}
str3 = tmp2.join("");
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.