String interpolation
Template literals let you embed variables and expressions directly inside strings. If you’ve used Python’s f-strings, this will feel instantly familiar.`), not quotes. Variables go inside ${}.
- JavaScript
- Python
f"...", and ${} instead of {}.
Expressions inside template literals
You can put any JavaScript expression inside${} — math, function calls, ternary operators, method calls.
Multi-line strings
Template literals preserve line breaks. No need for\n characters or string concatenation.
Building HTML strings
You’ll sometimes build HTML strings in JavaScript — especially before you learn React. Template literals make this readable.Once you learn React in Section 7, you’ll use JSX instead of building HTML strings. But it’s useful to see this pattern first — it shows why template literals matter for web development.
Common mistakes
Using quotes instead of backticks
Using quotes instead of backticks
Forgetting the dollar sign
Forgetting the dollar sign
What’s next?
You can build dynamic strings. Before we move to functions, let’s cover one quick topic — comments.Comments
Add notes and documentation to your JavaScript code