Template strings are string literals that allow for embedded expressions and support both single and multiline strings. They are enclosed in backticks and allow expressions indicated by a dollar sign and curly braces. The document provides the syntax for template strings and examples of single line, multiline, and expressions used in template strings.
3. Introduction
Template strings are string literals allowing embedded expressions.
It supports single as well as multiline support.
Template strings are enclosed by the back-tick ( ` ` ).
The expressions are indicated by the Dollar sign and curly braces like $ {
expression }.
4. Syntax
Single Line
` string text `
Multi Line
` line one content
line two content `
Expressions
` string message $ { expression } `;
5. Live Examples
Single Line
console.log( ` string text ` );
Multi Line
console.log(` line one content
line two content `);
Expressions
var a = 10, b = 20;
Console.log(` string message $ { a + b } `);