I have this nested arrays.
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["JavaScript", "Gaming", "Foxes"]
}
];
I know how to access a property within an array like this:
contacts[0][firstName]
to get "Akira"
. But I wanted to display the first array within the nested arrays. How do I do this? If I just type in console.log(contacts[0]);
I get [object Object]
.
I heard about JSON.parse(). Is it the correct way to display the first array within the nested arrays or any other array too?