Question 13
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
const [a = "x", b = "y", c = "z"] = [, null];
console.log(a, b, c);
- A x null z Correct
- B x y z
- C undefined null z
- D x null undefined
Correct Answer: Option A
A hole and a missing item both read as undefined, so a and c get defaults; null is kept for b.
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!