js create nested object code example

Example 1: 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"

Example 2: js create nested object from fields

var settings = {};
assign(settings, ['Modules', 'Video', 'Plugin'], 'JWPlayer');

Example 3: javascript nested objects

Do my eyes decieve me, or is the second answer the same as the first, but
with more upvotes?

Tags:

Misc Example