Template Literals & Optional Chaining in JavaScript

🟢 Beginner Level | JavaScript Core Syntax

📖 Definition

Template Literals enable string interpolation (`${expr}`). Optional Chaining (?.) safely reads nested properties without throwing error. Nullish Coalescing (??) returns fallback for null/undefined.

âš¡ Code Example

const user = { profile: { email: "alex@domain.com" } };
console.log(user?.profile?.email); // "alex@domain.com"
console.log(user?.settings?.theme ?? "light"); // "light"

🧭 Navigation

← 02. Destructuring & Rest/Spread Operators | Module Hub | Module Hub →