Expression Interpolation with ${}
What you'll learn: How to embed live JavaScript values and calculations directly inside template literals using ${} syntax.
The Power of ${}
When you use template literals (backticks), you unlock a superpower: the ability to insert JavaScript expressions right into your strings using ${}. Anything you place inside the curly braces gets evaluated as JavaScript code, converted to a string, and inserted at that exact spot.
Think of ${} like a window inside your string. Whatever JavaScript you write inside that window gets "looked through" — the computer evaluates it, sees the result, and displays that result in your string.
Basic Syntax
let name = "Alice";
let greeting = `Hello, ${name}!`;
console.log(greeting); // "Hello, Alice!"
The ${name} is replaced by the value stored in name.
Expressions, Not Just Variables
You can put any valid JavaScript expression inside:
let price = 20;
let message = `The total is $${price * 2}`;
console.log(message); // "The total is $40"
let a = 5;
let b = 3;
let result = `${a} plus ${b} equals ${a + b}`;
console.log(result); // "5 plus 3 equals 8"
Notice how ${price * 2} performs the calculation first, then inserts the result (40) into the string.
Why This Matters
Before template literals, building strings with variables required awkward concatenation with +. Now you can write natural-looking strings with embedded values that update automatically.
Key Takeaway: ${} inside template literals evaluates any JavaScript expression and inserts its value directly into your string, making dynamic text creation clean and readable.