- Executors
-
Learn
Learn Python Runnable examples, NumPy, pandas, and more Learn AI / Machine LearningNeural networks, ML and LLMs from scratch Learn C & C++ Pointers, memory, STL, and modern C++ Learn C#C# basics, OOP, LINQ, async, and .NET exercises Learn MatplotlibLine, bar, scatter and pie charts with live visualizers Learn RustOwnership, traits, error handling, and threads Learn GoSlices, interfaces, goroutines, and channels Python Algorithms Search, sorting, recursion, and visualizers O(n) C & C++ Algorithms Compare algorithms implemented in C and C++ Coding for Kids Learn to code by playing!
- QuizzesNew
- ChallengesNew
- For TeachersNew
- Updates
- Buy me a coffee
JavaScript Optional Chaining & ?? Quiz
This JavaScript quiz covers optional chaining (?.) and the nullish coalescing operator (??). You will predict what they return for missing values, compare ?? with ||, and choose the safe way to read nested data.
Sample question
Question 1 of 10What does this print?
const user = { profile: null };
console.log(user.profile?.name);
Show the answer
C. undefined ?. checks the value on its left. user.profile is null, so the expression stops and returns undefined instead of throwing. Note it returns undefined, not null.
What this quiz covers
?.on properties,?.[]on indexes and?.()on calls- How
?.stops the rest of the expression ??vs||with0and""- The
??=assignment - Which values count as nullish
Questions people ask
Do I need an account?
No. Anyone can play. Sign in to keep your XP, streak, badges and history.
Can I retake it?
Yes. Your best score is kept, and the questions and answers are shuffled each time.