Home > Net >  JavaScript, Data Structure, Array Methods
JavaScript, Data Structure, Array Methods

Time:10-13

Can you please explain me why if I have this array: var array2 = ["Banana", ["Apples", ["Oranges"], "Blueberries"]];

to access "Oranges" i have to do: array2[1][1][0]; ?

CodePudding user response:

Indices start from 0, so:

array2[1] == ["Apples", ["Oranges"], "Blueberries"]
array2[1][1] == ["Oranges"]
array2[1][1][0] == "Oranges"
  • Related