In the snippet below, values are assigned with a mix of parentheses and square brackets without any errors. However, most other combinations (such as parentheses inside square brackets) do not work at all.
var myItems = [];
myItems[5] = ("A1", "B1", ["C1","C2","C3"]);
When printed in different browsers, the values remain consistent.
myItems[5]: C1,C2,C3
myItems[5][0]: C1
myItems[5][1]: C2
myItems[5][2]: C3
myItems[5][2][0]: C
myItems[5][2][1]: 3
myItems[5][2][2]: undefined
It appears that only the content within the square brackets is being recognized. Is this outcome dictated by the JavaScript standard (ECMA-262)? Or is it simply how the interpreter/engine (Chrome and Firefox in this scenario) handled an invalid usage?
var myItems = [];
//myItems[5] = ["A1", "B1", ["C1","C2","C3"]];
myItems[5] = ("A1", "B1", ["C1","C2","C3"]);
document.getElementById("demo").innerHTML =
"myItems[5]: " + myItems[5] + "<br/>" +
"myItems[5][0]: " + myItems[5][0] + "<br/>" +
"myItems[5][1]: " + myItems[5][1] + "<br/>" +
"myItems[5][2]: " + myItems[5][2] + "<br/>" +
"myItems[5][2][0]: " + myItems[5][2][0] + "<br/>" +
"myItems[5][2][1]: " + myItems[5][2][1] + "<br/>" +
"myItems[5][2][2]: " + myItems[5][2][2] + "<br/>" +
"";
<p id="demo"></p>
EDIT: While I understand the correct use of brackets (as demonstrated in my fiddle), I'm questioning if the result is deterministic with such incorrect usage. As the interpreters I've tested show no error and yield identical outcomes, I am curious whether these results are guaranteed by the standard and/or if other interpreters would behave similarly.