String Concatenation

Benchmark created on


Setup

function main() {
  var str0 = "";

  var str1 = "Hello";
  var str2 = ",";
  var str3 = " World!";
  var str4 = "🌎";
  
  return [str0, str1, str2, str3, str4];
}

let [str0, str1, str2, str3, str4] = main();

Test runner

Ready to run.

Testing in
TestOps/sec
Adder Prototype
str0 += str1;
str0 += str2;
str0 += str3;
str0 += str4;
ready
Chain
str0 += str1 + str2 + str3 + str4;
ready
Naive Reassignment
str0 = str0 + str1;
str0 = str0 + str2;
str0 = str0 + str3;
str0 = str0 + str4;
ready
Joined Array
str0 = [str1, str2, str3, str4].join('');
ready
Concat Prototype
str0 = str0.concat(str1, str2, str3, str4);
ready
Function String
str0 = `${str1}${str2}${str3}${str4}`
ready

Revisions

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