How to perform string interpolation in TypeScript?

zshanabek picture zshanabek · Jul 30, 2017 · Viewed 104.2k times · Source

C# uses string interpolation

int value = 100;
Console.WriteLine($"The size is {value}.");

Output:

The size is 100.

How to do the same thing in TypeScript?

Answer

Nitzan Tomer picture Nitzan Tomer · Jul 30, 2017

In JavaScript you can use template literals:

let value = 100;
console.log(`The size is ${ value }`);