Array Join vs String Concatenation

JavaScript performance comparison

Revision 2 of this test case created

Info

http://redd.it/10pc5p

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Array Join
var name = 'Bob';
var text = [];
var x = Math.floor(Math.random(10000));

text.push('Hello ', x++);
text.push(name, x++);
text.push(" how's your day going?", x++);
text.push('My day is going fine thanks ', x++);
text.push(name, x++);

text = text.join('');
pending…
String Concatenation
var name = 'Bob';
var text = '';
var x = Math.floor(Math.random(10000));

text += 'Hello ' + x++;
text += name + x++;
text += " how's your day going?" + x++;
text += 'My day is going fine thanks ' + x++;
text += name + x++;
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