const user = { profile: null };
user.profile?.address?.city; // undefined, no error
// Without ?. this would throw: Cannot read properties of null- Short-circuits to undefined the moment it hits null/undefined
- Works for property access (?.), function calls (?.()) and array indexing (?.[0])
- Pairs perfectly with the nullish coalescing operator (??) for a default value