JavaScript Template Literals


Synonyms:

  • Template Literals
  • Template Strings
  • String Templates
  • Back-Tics Syntax

Back-Tics Syntax

Template literals use back-ticks (``) instead of double quotes (") to create a string.


Quotes Inside Strings

You can include both single and double quotes in a string using template literals.


Multiline Strings

Template literals allows multiline strings:


Interpolation

Template literals make it simple to insert variables and expressions into strings.

The method is called string interpolation.

The syntax is:

${...}

Variable Substitutions

Template literals make it possible to use variables within strings.

String interpolation refers to the automatic replacement of variables with their actual values.


Expression Substitution

Sure, here's a simpler and more precise version of the given text while retaining the HTML tags and class: Template literals enable the use of expressions within strings.


HTML Templates