String interpolation ( $ )
Embeds a variable/expression into text.
Syntax
"$variable" or "${expression}"Description
Writing $variable inside double quotes inserts its value into the text. Use ${...} for an expression. The most readable way to concatenate strings.
Example
Loading editor…
Expected output
Alex 36 years old Next year: 37
When to use?
Printing variables by combining them with text.
Common mistakes
- ⚠️ Trying to add a number to text with + causes an error; embed it using $.