let planets = {
"count": 60,
"next": "https://swapi.dev/api/planets/?page=2",
"previous": null,
"results": [
{
"name": "Tatooine"
},
{
"name": "Alderaan"
}
]
}
console.log((planets[Object.keys(planets)[3]][0].name))
data = {"id":1,
"name":"abc",
"address": {"streetName":"cde",
"streetId":2
}
}
data.address.streetName; //Retrieves "cde"
//or
data["address"]["streetName"]
let planets = {
"count": 60,
"next": "https://swapi.dev/api/planets/?page=2",
"previous": null,
"results": [
{
"name": "Tatooine"
},
{
"name": "Alderaan"
}
]
}
console.log((planets[Object.keys(planets)[3]][0].name))
data = {"id":1,
"name":"abc",
"address": {"streetName":"cde",
"streetId":2
}
}
data.address.streetName; //Retrieves "cde"
//or
data["address"]["streetName"]