Reputation: 2378
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
Reputation: 1282
maybe: console.log(businessDetails[8][0].businessDetails.companyName)
Upvotes: 1