What are template literals in JavaScript?

const name = "Robin";
const age = 25;

console.log(`Name: ${name}, age next year: ${age + 1}`);
console.log(`Line 1
Line 2`);

Output:

Tutorials Class - Output Window

Name: Robin, age next year: 26
Line 1
Line 2

Backticks give string interpolation with ${ } and allow multi-line strings. See JavaScript Strings.


Learn more about the similar topics:
Tutorials
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.