JavaScript Template Literals Basic interpolation and multiline strings


Template literals are a special type of string literal that can be used instead of the standard '...' or "...". They are declared by quoting the string with backticks instead of the standard single or double quotes: `...`.

Template literals can contain line breaks and arbitrary expressions can be embedded using the ${ expression } substitution syntax. By default, the values of these substitution expressions are concatenated directly into the string where they appear.

const name = "John";
const score = 74;

console.log(`Game Over!

${name}'s score was ${score * 10}.`);
Game Over!

John's score was 740.