Do you know what will be the output of this code?
JavaScript
let a = 1;
let b = 2;
[a, b] = [b, a];
console.log(a, b);
Show answer and explanation
The answer is 2 1.
The right side creates a new array [2, 1] first, then destructuring assigns its items to a and b.