LearnFrenzy
Sign in Take a free test

Destructuring · Destructuring MCQ · Question 6

Destructuring null Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 6 Back to Exercise

What happens with const { id } = null;?

  • A id becomes undefined
  • B id becomes null
  • C A SyntaxError
  • D TypeError: Cannot destructure property 'id' of null Correct
Correct Answer: Option D

null and undefined have no properties, so destructuring them throws. (value ?? {}) avoids it.

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