Rizki Syukur
last year
Rizkicountry asked

What is the big difference between template literals and normal quotes in JavaScript?

Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Hi Rizki,

Normal quotes (" " or ' ') make a basic string. Template literals use backticks ) and give you two big benefits:

  1. Easy variables inside the string using ${}

let name = "Ali";
console.log(`Hello ${name}`);

With normal quotes you usually do:

console.log("Hello " + name);
  1. Multi-line strings without adding \n

console.log(`Line 1
Line 2`);

So template literals are mainly for cleaner formatting and easier mixing of text + variables.

If you have more questions, I am here to help 😊

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