How can I do string interpolation in JavaScript?

Since ES6, you can use template literals:

const age = 3
console.log(`I'm ${age} years old!`)

Expand snippet

P.S. Note the use of backticks: ``.

Leave a Comment