0
var fighters = ['johnjones', 'rondarousey', 'connormcgregor', 'chuckliddel', 'demetriusjohnson'];

var warriors = {
  wrestlers: ['randysavage', 'hulkhogan', 'ultimatewarrior', 'jakethesnake', 'milliondollarman'],

  stable: [fighters, warriors.wrestlers]
}

I believe I can reference fighters from stable, but can I reference wrestlers from stable? In other words, how do I reference a key value pair from a later key value pair within the warriors object. Thank you for any and all help!

J. Bones
  • 459
  • 1
  • 5
  • 9

1 Answers1

0

You cannot do that until the variable warriors is initialized. The only way is to wait and assign in the next line:

var warriors = {
  wrestlers: ['randysavage', 'hulkhogan', 'ultimatewarrior', 'jakethesnake', 'milliondollarman'],
}
warriors.stable = [fighters, warriors.wrestlers]

Or use some kind of weird initialization like the one described here. Or use function constructor.

Community
  • 1
  • 1
Max Koretskyi
  • 101,079
  • 60
  • 333
  • 488