[Js] 객체 안의 객체 접근/ 객체 안의 배열 접근

eunkyung·2022년 12월 15일
0

function accessObject() {

const myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"}
,
"outside": {
"trunk": "jack"}
}
};

let gloveBoxContents = myStorage['car']['inside']['glove box']

return gloveBoxContents;

console.log(accessObject())

2) 객체 안의 배열 접근

unction accessArray() {

const myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];

let foundValue = myPlants[1].list[1]

0개의 댓글