Just imagine I have a nested object like the following one:
{
"post":{
"hello":{
// what's in here doesn't matter
}
"test":{
// also doesn't matter
}
}
and is there any way to get the object name inside post to an array like this:
["hello", "test"]
答案 0 :(得分:0)
Try this Object.keys(a.post)
var a = {
"post": {
"hello": {
// what's in here doesn't matter
},
"test": {
// also doesn't matter
},
}
}
console.log(Object.keys(a.post))