Concatenation vs Array Join

JavaScript performance comparison

Revision 16 of this test case created by Andrew Barrett

Preparation code

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

2 comments

affiliate marketing commented :

What's up Dear, are you really visiting this web site on a regular basis, if so afterward you will without doubt get pleasant experience.

gossard bras online commented :

I constantly spent my half an hour to read this web site's articles every day along with a mug of coffee.

Add a comment