Loading Please Wait...
Template Literals use back-ticks (``) rather than the quotes ("") to define a string.
let text1 = "Hello World!";
let text2 = 'Hello World!';
let text3 = `Hello World!`;
With template literals, you can use both single and double quotes inside a string.
let text = `He's often called "Johnny"`;
Template literals allows multiline strings
let text =
`Lynxsia
IT
Solutions`;
Template literals provide an easy way to interpolate variables and expressions into strings. The method is called string interpolation.
Syntax
${...}
Template literals allow variables in strings.
let firstName = "John";
let lastName = "Doe";
let text = `Welcome ${firstName}, ${lastName}!`;
Template literals allow expressions in strings.
let price = 10;
let VAT = 0.25;
let total = `Total: ${(price * (1 + VAT)).toFixed(2)}`;
Template literals allow us to use HTML in the string.
let header = "Lynxsia IT Solutions";
let html = `<h2>${header}</h2>`;
How you feel about this blog:
Share this blog on:
If you find any error in the turtorials, or want to share your suggestion/feedback, feel free to send us email at: info@lynxsia.com
Contact UsWe are concern with various development process like website design & development, E-commerce development, Software development, Application development, SMS & Bulk SMS Provider, PWA Development, and many more..
Copyright ©
, Lynxsia IT Solutions, All rights reserved