Advance JavaScript Course
About Lesson

Template literals are a new feature introduced in ECMAScript 2015/ ES6. It provides an easy way to create multiline strings and perform string interpolation. Template literals are the string literals and allow embedded expressions.

Before ES6, template literals were called as template strings. Unlike quotes in strings, template literals are enclosed by the backtick (` `) character (key below the ESC key in QWERTY keyboard). Template literals can contain placeholders, which are indicated by the dollar sign and curly braces ($(expression}). Inside the backticks, if we want to use an expression, then we can place that expression in the ($(expression}).

Syntax

var str = `string value`;  

Multiline strings

In normal strings, we have to use an escape sequence n to give a new line for creating a multiline string. However, in template literals, there is no need to use n because string ends only when it gets backtick(`) character.

Exercise Files
No Attachment Found
No Attachment Found
Join the conversation

Introducing Official ApeStaking Protocol for ApeCoin.

New Blur NFT Marketplace Courting Professional.