Template literal ( `` )
Embeds a variable/expression inside text.
Syntax
`text ${expression} text`Description
Written with backticks (`); you put variables or expressions inside ${ }. It is much more readable than concatenating with +. It also allows multiline text.
Returns
Concatenated text (string).
Example
Loading editor…
Expected output
Alex scored 95
When to use?
Combining variables with text, HTML/message templates.
Common mistakes
- ⚠️ Instead of normal quotes ' ", backticks ` should be used.
- ⚠️ Writing {} instead of ${} does not insert the value.