A few coworkers and I have come across some more strange JavaScript syntax. We are having trouble explaining the following behaviour (I am using the Chrome console):
> {}[1]
Yields
[1]
Essentially, it is valid syntax to include any object (not just empty) before the array, and the result is always just the array. Is there any explanation for this? Any case where this doesn't behave this way?
Also, this question is sort of hard to search for, since it consists of characters that don't play well with search engines. Please let me know if this is a duplicate question.
{ a: 'b' }[1]yields[1]ais the label,'b'is a String literal expression statement). AST explorer.