Template Literals
Template literals use backtick quotes instead of normal quotes. They let you embed values directly inside a string using the ${ } placeholder.
They also support multi-line strings without needing the \n escape.
const name = "Ada";
const msg = `Hello, ${name}!`;
const box = `Line one
Line two`;
- Wrap the string in backticks
- Insert any expression with ${ }
- Great for building messages and HTML
Anything inside ${ } is evaluated as JavaScript, so you can do math or call functions there.
Try it yourself
Loading editor…