What are template literals and what can you do with them?
A template literal is a string written between backticks instead of quotes. That single change buys you three things: you can drop values into the middle of the text, you can write across several lines without escaping, and you can hand the whole thing to a function as a tagged template.
const name = "Ada";
const score = 96.5;
const greeting = `Hello ${name}, you scored ${score} points`;
console.log(greeting);
// Expressions and method calls work inside the substitution.
console.log(`Upper: ${name.toUpperCase()}`);
console.log(`Rounded: ${(score / 100).toFixed(2)}%`);The substitution syntax evaluates the expression between the dollar sign and the brace and converts the result to a string. Anything legal in an expression is legal there, including ternaries, arithmetic and function calls. The result is always a string, so an object becomes its usual text form.
The second feature is multiline strings. A template literal can contain literal line breaks, and the newlines are part of the string. That removes a pile of concatenation with newline characters, which used to be the main reason people reached for array joins.
The third is escaping. A backslash inside a template literal still works, but the backtick itself can be included with a backslash, and the dollar-brace sequence can be escaped with a backslash as well, which is how you write a literal dollar-brace in text.
The trade-off worth mentioning is that template literals are not a general-purpose formatter. If you build a long string with many substitutions, the concatenation is faster and the result is easier to read in a diff.