Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Accessing Nested Objects

The sub-properties of objects can be accessed by chaining together the dot or bracket notation.
Here is a nested object:

const ourStorage = {
  "desk": {
    "drawer": "stapler"
  },
  "cabinet": {
    "top drawer": { 
      "folder1": "a file",
      "folder2": "secrets"
    },
    "bottom drawer": "soda"
  }
};

ourStorage.cabinet["top drawer"].folder2;
ourStorage.desk.drawer;
Source by www.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #Accessing #Nested #Objects
ADD COMMENT
Topic
Name
3+3 =