What is the best way to combine strings in JavaScript?

In this tutorial, I will show you some ways to combine multiple strings in JavaScript.

1. JavaScript concatenation operator +

Use the JavaScript concatenation operator (+) to combine multiple strings.

const a = "Apple";
const b = "Banana";

const c = a + " and " + b;

console.log(c)
Apple and Banana

2. JavaScript Assignment Operator +=

You can use the assignment operator (+=) to concatenate strings. This operator will assign value into an existing variable.

let a = "🏏 Bat";
a += " and Ball";

console.log(a);
🏏 Bat and Ball

3. JavaScript template literals

You can easily concatenate multiple strings using JavaScript template literals (``).

const a = "Cricket";
const b = "Football";

const c = `I love to play ${a} as well as ${b}.`;

console.log(c);
I love to play Cricket as well as Football.

4. JavaScript String concat() method

The String concat() method joins two or more strings and it does not change the existing strings, it will return a new string.

const a = "🏏 Cricket";
const b = "Football ⚽";

const c = a.concat(" and ", b);

console.log(c);
🏏 Cricket and Football ⚽