如何在JavaScript中获取数组的对象名?
{
"Ford F-150": [
{
"year": 2007,
"model": "Ford F-150"
},
{
"year": 2007,
"model": "Ford F-150"
},
{
"year": 2007,
"model": "Ford F-150"
}
],
"Toyota Camry": [
{
"year": 2011,
"model": "Toyota Camry"
}
],
"Dodge RAM": [
{
"year": 2005,
"model": "Dodge RAM"
}
]
}
我希望结果如
var result = ["Ford F-150", "Toyota Camry", "Dodge RAM"]
答案 0 :(得分:0)
使用此属性访问对象的键
Object.keys(your_obj);