let myArray = [1,2,3,4] myArray[0,1] // 2 myArray[1,3] // 4 myArray[3,0] // 1
It's not improper syntax.
The comma operator evaluates each of its operands (from left to right) and returns the value of the last operand.
[1,2][1,2], perhaps bizarrely enough, will return
Thus, the second
1,2 must be an expression that evaluates to an index.
1,2 results in the first operand being evaluated, followed by the second, which is what's returned. So it uses index
2, which of course doesn't exist in that array, and we get