JS Coding Questions Logo
JS Coding Questions
#310💼 Interview💻 Code

What are template literals

Advertisement

728x90

Template literals or template strings are string literals allowing embedded expressions. These are enclosed by the back-tick (`) character instead of double or single quotes.

In ES6, this feature enables using dynamic expressions as below,

javascript
1var greeting = `Welcome to JS World, Mr. ${firstName} ${lastName}.`;

In ES5, you need break string like below,

javascript
1var greeting = 'Welcome to JS World, Mr. ' + firstName + ' ' + lastName.`

Note: You can use multi-line strings and string interpolation features with template literals.

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 54

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
310of476