Template strings

Template strings are just a new literal for creating strings, which makes various things easier. They provide features such as embedded expressions, multiline strings, string interpolation, string formatting, string tagging, and so on. They are always processed and converted to a normal JavaScript string on runtime; therefore, they can be used wherever we use normal strings.

Template strings are written using backticks instead of single or double quotes. Here is an example of a simple template string:

let str1 = `hello!!!`; //template stringlet str2 = "hello!!!";console.log(str1 === str2); //output "true"

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.