LearnFrenzy
Sign in Take a free test

Destructuring · Destructuring MCQ · Question 7

Destructuring into existing variables Answer, explanation & discussion

  • MCQ
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 7 Back to Exercise

Variables a and b already exist. Which statement assigns obj.a and obj.b to them?

  • A { a, b } = obj;
  • B ({ a, b } = obj); Correct
  • C let { a, b } = obj;
  • D [a, b] = obj;
Correct Answer: Option B

Without parentheses the leading { starts a block, which is a SyntaxError. let would redeclare the variables, and an array pattern needs an iterable.

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