concat vs + vs join (v53)

Revision 53 of this benchmark created on


Description

How to concat strings faster.

Setup

var data = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    
    var position;
    
    position = Math.floor((Math.random() * 21) + 1);
    var a = data.slice(position, position + 5);
    position = Math.floor((Math.random() * 21) + 1);
    var b = data.slice(position, position + 5);
    position = Math.floor((Math.random() * 21) + 1);
    var c = data.slice(position, position + 5);

Test runner

Ready to run.

Testing in
TestOps/sec
concat
a.concat(b, c);
ready
+
a + b + c;
ready
join
[a, b, c].join();
ready

Revisions

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