See for yourself below:
Of course, the array with two elements returns
undefined as expected.
What is even more insane, is that the array can be of any depth as long as it is a single element array within a single element array within a single element array etc. How weird is that?
Digging deeper, I discovered that it is possible to index an object with arrays on any dimension and that would be equivalent as indexing with the elements joined with a comma. Here’s a demonstration
Again, it does not matter whether the array is deeply nested inside other arrays
I imaging this can actually be quite useful though I’d be afraid that programmers not familiar with this trick would not understand what is happening.
A superfluous google search didn’t answer why this works like that. A comment with an explanation will be greatly appreciated .