Question 9
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
let a = 1, b = 2, c = 3;
[a, b, c] = [c, a, b];
console.log(a, b, c);
- A 1 2 3
- B 2 3 1
- C 3 1 2 Correct
- D 3 3 3
Correct Answer: Option C
The right-hand array [3, 1, 2] is built from the old values first, then assigned in order.
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!