1

Is it possible to navigate through an object in JavaScript, referencing one 'area'/section of the object in another?

For example, if I have an object which is structured like below:

var config = {
    resources: {
        styles: 'path/to/a/stylesheet',
        scripts: 'path/to/a/javascript/file'
    },
    options: {
        plugin_a: {
            entries: [config.resources.styles, config.resources.scripts]
        }
    }
}

Is it possible for me to, for example, reference the path to my styles and scripts files in 'config.resources.styles' and 'config.resources.scripts' in the 'config.options.plugin_a' section?

Thanks

Alex Ryans
  • 1,865
  • 5
  • 23
  • 31

1 Answers1

0

You could do it in two separate lines: create the config object, then set config.options to the object using config values. Instead of var a={b:1,c:a.b} use var a={b:1}; a.c=a.b;

Siderite Zackwehdex
  • 6,293
  • 3
  • 30
  • 46