Template String

var name="Hemant", 
    loc = "Hyderabad";

var str = `
    my name is ${name}, 
    I am stying in ${loc}`;

console.log(str);

// output
    my name is Hemant, 
    I am stying in Hyderabad

Use Case 1 ( variable manipulation )

var x =1, y=2;

var str = `sum of 
    ${x} + ${y} = ${x +y}
`;

console.log(str);

// output
sum of 
    1 + 2 = 3

Use Case 2

Last updated

Was this helpful?