Concatenation vs Array Join (v8)

Revision 8 of this benchmark created by Leonardo Dutra on


Preparation HTML

<script>
  var i, str;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Concatenation: string + string
str = '';
i = 0;
while (i++ < 100) {
 str += 'a';
}
ready
Buffer: Array.prototype.join
str = [];
i = 0;
while (i < 100) {
 str[i++] = 'a';
}
str = str.join('');
ready
String index: 'string'[index]
// This has compatibility issues (mainly IE)
str = '';
i = 0;
while (i < 100) {
 str[i++] = 'a';
}
ready

Revisions

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