JS Objects & Destructuring
Lesson Overview: Model structured records using objects, methods, destructuring, and optional chaining (?.).
Objects & Modern Shorthand
Objects store named properties and methods. Object destructuring ({ name, role } = user) extracts fields concisely, and optional chaining (user?.address?.city) prevents crashes on missing nested keys.
Destructuring & Optional Chaining (Editable — type & Run)
Live Output (JavaScript)
Test Yourself With Exercises
Safely access user.profile.email without throwing if profile is null:
const email = user?.
?.email;
Pro Tip: Use Object.keys(), Object.values(), and Object.entries() to iterate over objects.