- Instant help with your JavaScript coding problems

Concatenate strings in JavaScript

How to concatenate strings in JavaScript?
const str1 = 'Hello'.concat(', ', 'John'); // Hello, John

const str2 = 'Hello' + ', ' + 'John'; // Hello, John

If you want to extend an existing string with additional string(s), then you can use the contact method. The concat() method concatenates the string arguments to the calling string and returns a new string.

However, it is strongly recommended - for performance reasons - to use the assignment operators (+, +=) instead of the concat() method.

Share "How to concatenate strings in JavaScript?"
Related snippets:
concat, concatenate, add, join, javascript, concatenate strings
Technical term:
Concatenate strings in JavaScript