How can I access the first property of a nested property?

Viewed 22

enter image description here

Every pages property has a first property with a random name. How can I access this property?

I thought about pages[0] but it's not an array.

I'm dealing with an API.

2 Answers

Use Object.values() to convert the object to an array, then get the first value.

Object.values(pages)[0]

As long as there is only one nested object, you can use this to get the driver object.

pages[Object.keys(pages)[0]]
Related