Expressions and template literals let you perform computations and format dynamic strings cleanly.
1. Arithmetic & Logical Operators
⊞Code Example
const userAge = 20;
const hasLicense = true;
// Strict comparison
console.log(5 === "5"); // false (number !== string)
console.log(5 == "5"); // true (type coercion - avoid!)
// Logical condition
if (userAge >= 18 && hasLicense) {
console.log("Eligible to drive!");
}
2. ES6 Template Literals ( )
Template literals use backticks to support multi-line strings and direct expression interpolation using ${expression}.
⊞Code Example
const student = "Alex";
const score = 95;
const course = "Full Stack Web Dev";
// Clean string interpolation
const greeting = `Hello ${student}! Your final score in ${course} is ${score}%.`;
console.log(greeting);
