Array Join vs String Concatenation

Benchmark created on


Description

http://redd.it/10pc5p

Test runner

Ready to run.

Testing in
TestOps/sec
Array Join
var name = 'Bob';
var text = [];

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

text = text.join('');
ready
String Concatenation
var text = '';
var name = 'Bob';

text += 'Hello ' + name + " how's your day going?";
text += 'My day is going fine thanks ' + name;
ready
Array.join()
var name = 'Bob',
    text = ["Hello ", name, " how's your day going?", "My day is going fine thanks ", name].join(" ");
ready

Revisions

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