I was reading through Kyle Simpson's book (You don't Know JS - ES6 and beyond) and he gives this example on reordering arrays:
var a1 = [ 1, 2, 3 ],
a2 = [];
[ a2[2], a2[0], a2[1] ] = a1;
console.log( a2 ); // [2,3,1]
Can someone help me understand what's happening (I was expecting it to return [3, 1, 2]). If I input other elements, it gets more confusing:
[ a2[2], a2[0], a2[0] ] = a1; // [3, undefined, 1]
[ a2[1], a2[0], a2[0] ] = a1; // [3, 1]