JavaScript Interview Question #16
What are template literals in JavaScript?
JavaScript Fundamentals, Types, Scope & Functions Junior Beginner
Quick Interview Answer
Template literals are string literals written with backticks. They support embedded expressions through ${...}, multi-line strings, and tagged template functionality.
Detailed Explanation
Template literals are string literals written with backticks. They support embedded expressions through ${...}, multi-line strings, and tagged template functionality.
They are often clearer than repeated string concatenation when building messages or combining values. Expressions inside ${...} are evaluated and converted into the resulting string.
Code Example
const name = "Asif";
const score = 90;
const message = `Hello ${name},
your score is ${score}.`;
console.log(message);