// v---- 1. v---- 3.
a = [b][b = a, 0];
// ^---^-- 2.
Put the value of the b
variable in a new Array.
The next set of square brackets is the member operator used for getting the index. In this case, that space is being used to reassign the value of the a
variable to the b
variable. This can be done because the original value of b
is safely in the Array (from step 1.).
Separated by comma operator, the 0
index is then used as the actual value of the Array being retrieved, which if you'll recall is the original b
value. This is then assigned to a
via the first =
assignment on the line.
So to summarize, b
is put in the Array, and is retrieved via the 0
index and assigned to a
on the left, but not before a
is assigned to b
(borrowing the space of the []
member operator).
This could also be written like this:
a = [b, b = a][0];
Only difference now is that the second index of the Array is used to do the assignment. Probably a little clearer like this.