Question 15
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
const key = "score";
const { [key]: s, [`${key}2`]: s2 = 0 } = { score: 9 };
console.log(s, s2);
- A 9 undefined
- B undefined 0
- C 9 9
- D 9 0 Correct
Correct Answer: Option D
Computed keys are evaluated to "score" and "score2". score2 does not exist, so the default 0 is used.
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!