Javascript template literals are enclosed by the back-tick ( ) character instead of the double or single quotes. These are indicated by a dollar sign and curly braces (${expression}). Template literals are the string literals allowing embedded expressions. You can use the multi-line strings and string interpolation features with them.

Javascript Template Literals

Template literals are quite simply the easiest way to improve your JavaScript code readability when working with Strings. Let’s break down a Template Literal.

  • template is a preset_ format._
  • literal is a value written_ precisely as it’s meant to be _interpreted.

Template Literals are the new ES2015 / ES6 feature that allows you to work with strings in a great way compared to ES5 and below. The syntax at first glance is straightforward, use backticks instead of single or double-quotes.

const madTitan = `Thanos`;

#javascript #expression #js

Javascript String Interpolation | Javascript Template Literals
3.20 GEEK