Utilizor
Contact Us

Template Literals

String interpolation with backticks.

Template Literals

Template Literals use back-ticks (``) rather than the quotes ("") to define a string.

Template literals allow variables in strings:

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)}`;

Example

let user = "John";
let greeting = `Hello ${user}!`;