Loading…
A short voice session: one question, one follow-up, then instant feedback — up to 5 minutes.
Optional chaining stops on null or undefined and returns undefined. ?? supplies a fallback only for a nullish result.
If user or user.address is null or undefined, user?.address?.city returns undefined instead of throwing for that access. If city is "", then user?.address?.city ?? "Unknown" preserves the empty string, while || "Unknown" replaces it. Optional chaining does not catch exceptions from getters or functions and does not make an undeclared variable safe to access.