concat vs + vs join

Benchmark created by Nick McCurdy on


Setup

function randomString() {
    return Math.random().toString(36).substr(2, 5);
  }
  
  var string1 = randomString();
  var string2 = randomString();
  var string3 = randomString();

Test runner

Ready to run.

Testing in
TestOps/sec
concat
string1.concat(string2, string3);
ready
+
string1 + string2 + string3;
ready
join
[string1, string2, string3].join();
ready

Revisions

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

  • Revision 1: published by Nick McCurdy on