0d: 00h: 00m: 00s

šŸŽ Get 3 extra months of learning — completely FREE

That's 90 extra days to master new skills, build more projects, and land your dream job.

Become a PRO
Background Image

šŸŽ Get 3 extra months of learning completely FREE

Become a PRO
khushbu Pathe
PRO
last week
Khushbucountry asked

What are template literals in JavaScript?

Abhay Jajodia
Expert
8 hours ago
Abhay Jajodia answered

Template literals are another way to write strings in JavaScript using backticks instead of quotes. The helpful thing about them is that you can drop variables straight into the string without breaking it apart.

Here’s a full example so you can see it in action:

let name = "Hushbu";
let city = "Mumbai";

let message = `Hi ${name}, you live in ${city}. Nice to meet you!`;

console.log(message);

When you run it, you’ll get:

Hi Hushbu, you live in Mumbai. Nice to meet you!

You can also make multi-line strings with template literals, which keeps things easy to read.

If anything here feels unclear or you want more examples, I’m here to help.

JS
This question was asked as part of the Learn JavaScript Basics course.