join/concat

JavaScript performance comparison

Revision 24 of this test case created

Info

A simpler check for testing for concat vs join outside of a loop (not building a string in a loop, typical use case would be to use a var in the string).

Preparation code

<script>
  var str = 'string';
  var barr = ['this', ' is', ' a', str, ' to', ' test', ' if', ' there', ' is', ' any', ' difference', ' between', ' concat', ' and', ' join'];
  var sarr = ['this', ' is', ' a', str];
</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
concat
var a = 'this' + ' is' + ' a' + str + ' to' + ' test' + ' if' + ' there' + ' is' + ' any' + ' difference' + ' between' + ' concat' + ' and' + ' join';
pending…
join
var a = barr.join('');
pending…
concat shorter
var a = 'this' + ' is' + ' a' + str;
pending…
join shorter
var a = sarr.join('');
pending…
concat in a loop
var str = '';
for (var i = 0; i < barr.length; i++) {
  str += barr[i];
}
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