I’m reading JavaScript the definitive guide and there is code:
var o = {x:1,y:{z:3}}; // An example object
var a = [o,4,[5,6]]; // An example array that contains the object
o.x // => 1: property x of expression o
o.y.z // => 3: property z of expression o.y
o["x"] // => 1: property x of object o
a[1] // => 4: element at index 1 of expression a
a[2]["1"] // => 6: element at index 1 of expression a[2]
a[0].x // => 1: property x of expression a[0]
None of this except the last line is in question to me. How does a[0].x evaluate to 1? There is no property x belonging to the multidimensional array ‘a’. I don’t understand this. Is the property a[0].x being found in ‘o’? This is confusing to me…
Thanks in advance for any comments or answers…
The first line defines
o, and the second setsa[0]aso, so we have…Therefore:
This also means the following is true:
So you were correct in saying that the property
a[0].xbeing found ino.