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?

7

2 Answers

In JavaScript you can use template literals:

Template literals are literals delimited with backticks (`)

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

Just use special `

var lyrics = 'Never gonna give you up'; var html = `<div>${lyrics}</div>`; 

You can see more examples here.

6

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy