Basic Javascript (92/111) | Accessing Nested Arrays | freeCodeCamp
Full playlist 👉 • Basic JavaScript (1/111) | Comment Your Ja...
As we have seen in earlier examples, objects can contain both nested objects and nested arrays. Similar to accessing nested objects, Array bracket notation can be chained to access nested arrays.
Here is an example of how to access a nested array:
var ourPets = [
{
animalType: ""cat"",
names: [
""Meowzer"",
""Fluffy"",
""Kit-Cat""
]
},
{
animalType: ""dog"",
names: [
""Spot"",
""Bowser"",
""Frankie""
]
}
];
ourPets[0].names[1]; // ""Fluffy""
ourPets[1].names[0]; // ""Spot"
https://www.freecodecamp.org/learn/ja...