Optional Chaining Result
Multiple Choice Easy
Question
What does null?.x return?
Hint
Optional chaining short-circuits on null/undefined.
Explanation
null?.x returns undefined. The ?. operator short-circuits: if the left side is null or undefined, it returns undefined without evaluating the right side. This prevents "Cannot read property of null" errors. You can chain: obj?.prop?.subProp. It also works with calls: fn?.() and brackets: arr?.[0].
Related Resources
Related Lessons
- Objects
Learn JS objects.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.