Sorry if I mistyped the question, but I am not sure how to explain this question. I am showing the value that I want by code below. I have an array with named indexes:
const comments = [
{K6TTWcffVUQNryy19FrSVKYL6Wt2: {age:25,name:"john"}},
{AXYVWcffVUQNryy19FrSVKYL6Wt3: {age:35,name:"sue"}}
]
I am trying to find the named indxes of the array of objects. I mean I am trying to create an array of ["K6TTWcffVUQNryy19FrSVKYL6Wt2", "AXYVWcffVUQNryy19FrSVKYL6Wt3"]
using the above comments
array.
How can I achieve this?
3
Answers
In order to get the properties of an object you can use
for in
loop, orObject.keys(yourObj)
A combination of
Array::reduce()
andObject.keys()
:You could map the keys.