// v---- 1. v---- 3. a = [b][b = a, 0]; // ^---^-- 2.
Put the value of the variable b in a new array.
The next set of square brackets is the member statement used to get the index. In this case, this space is used to reassign the value of variable a variable b . This can be done because the original value of b safely in the array (from step 1).
Separated by a comma operator, then index 0 used as the actual value of the returned array, which, if you recall, is the original value of b . Then it is assigned a through first = assignment in the string.
So, to summarize, b is placed in an array and extracted using index 0 and assigned to a on the left, but not earlier than a assigned to b (borrowing the space of the member operator [] ).
This can also be written like this:
a = [b, b = a][0];
Now the only difference is that the second array index is used to complete the job. Probably a little clearer.
user1106925
source share