0 day streak
javascript / beginner
Snippet

Template Literals for Dynamic Strings

Template literals use backticks (`) instead of quotes. They allow you to embed variables directly into strings using the ${variable} syntax.

snippet.js
javascript
1
2
3
const name = 'Markus';
const greeting = `Welcome to Next.js, ${name}!`;
console.log(greeting);
nextjs
Breakdown
1
const greeting = `...`;
Uses backticks to define a string that supports interpolation.
2
${name}
Injects the value of the 'name' variable into the string.