Question 4
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
const { x: renamed = 10, y: other = 20 } = { x: undefined, y: 0 };
console.log(renamed, other);
- A 10 20
- B undefined 0
- C 10 0 Correct
- D 0 20
Correct Answer: Option C
x is undefined, so its default 10 is used; y is 0, a defined value, so the default 20 is ignored.
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!