Skip to content
Advertisement

Get the value of an Element in an array

i’m trying to get the value of a Object in my array. Basically when i’m doing

JavaScript

I have something like that

JavaScript

But the name of the object is changing every time, so i can’t do

JavaScript

I wondered if there was a way to directly get the value of the only object, without having to go through its name.

Advertisement

Answer

You can use the object.values

JavaScript

Which would return an array of the values in the object

Object.values(response.data)[0] would return the value if you have one

Advertisement