LearnFrenzy
Sign in Take a free test

Destructuring · Predict the Output · Question 3

Crossed renaming Answer, explanation & discussion

  • Output
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 3 Back to Exercise

What does the following JavaScript code print (console output, as in Node.js)?

main.js
const { a: b, b: a } = { a: 1, b: 2 };
console.log(a, b);
  • A 1 2
  • B undefined undefined
  • C 2 1 Correct
  • D SyntaxError
Correct Answer: Option C

Property a goes into variable b and property b into variable a.

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