user1532669
user1532669

Reputation: 2378

Meteor: accessing javascript object element within array element

If I log the following data structure I get the output below:

console.log(businessDetails[8])

[ 
  { businessDetails: 
       { companyName: 'Companyname' },
    _id: 'LrqSm5LJcxpo5wW7W' 
  } 
]

How can I access the companyName field?

I would've thought that I could do it like this:

console.log(businessDetails[8].businessDetails.companyName)

Unfortunately this doesn't work.

What do I need to do to access this element?

Upvotes: 0

Views: 90

Answers (1)

juliancwirko
juliancwirko

Reputation: 1282

maybe: console.log(businessDetails[8][0].businessDetails.companyName)

Upvotes: 1

Related Questions