LearnFrenzy
Sign in Take a free test

Conditional Statements · Conditional Statements MCQ · Question 14

Optional chaining in a condition Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 14 Back to Exercise

user is undefined. What happens with if (user?.isAdmin) { … }?

  • A The condition is undefined (falsy), so the block is skipped without an error Correct
  • B A TypeError is thrown
  • C The block runs
  • D A ReferenceError is thrown
Correct Answer: Option A

user?.isAdmin evaluates to undefined when user is null or undefined, and undefined is falsy.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links