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!