For strings plus (+) is faster than the function concat()

According to Mozilla, using a ‘+‘ or ‘+=‘ to concatenate strings is faster than concat(). You probably want some proof.

Here are the two versions:

‘Coucou ‘.concat(‘c\’est ‘, ‘nous !’);

‘Coucou ‘ + ‘c\’est ‘ + ‘nous !’;

Ignoring the ‘.join()‘ in this version, it is quite apparent that the ‘+wins hands down.

Even when doing nasty concatenation, it wins.

With very short strings, ‘concat()gets closer, but plus (+) still wins.

It turns out that ‘+=‘ and ‘= +‘ are nearly identical.

In every variation, ‘plus (+)wins.

Plus (+) wins