Answers for "how to access nested objects in javascript"

5

accessing nested objects javascript

var ourStorage = {
  "desk": {
    "drawer": "stapler"
  },
  "cabinet": {
    "top drawer": { 
      "folder1": "a file",
      "folder2": "secrets"
    },
    "bottom drawer": "soda"
  }
};
ourStorage.cabinet["top drawer"].folder2;  // "secrets"
ourStorage.desk.drawer; // "stapler"
Posted by: Guest on July-19-2020
1

nested objects javascript

var backPack = {
  color: 'black',
  straps: 4,
  isHeavy: true,
  wallet: {
	cash: '$10,000',
	creditCards: 6
  }
  tablet: {
	brand: 'Apple iPad',
  	buttons: 1
  }
};
Posted by: Guest on March-16-2021
1

javascript nested objects

Do my eyes decieve me, or is the second answer the same as the first, but
with more upvotes?
Posted by: Guest on March-15-2021
2

how to access nested objects in javascript

var ourStorage = {
  "desk": {
    "drawer": "stapler"
  },
  "cabinet": {
    "top drawer": { 
      "folder1": "a file",
      "folder2": "secrets"
    },
    "bottom drawer": "soda"
  }
};
ourStorage.cabinet["top drawer"].folder2;  // "secrets"
ourStorage.desk.drawer; // "stapler"
Posted by: Guest on July-09-2020
0

Accessing Nested Objects

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

var gloveBoxContents = myStorage.car.inside["glove box"]; // "maps"

console.log(gloveBoxContents); // to test your code
Posted by: Guest on December-19-2020

Code answers related to "how to access nested objects in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language