[英]How to get keys from map Object with javascript
I have this structure below: 我的结构如下:
/* Wrapper to format cellphone configuration list for selectors. */
function buildConfiguration(){
return {
"Item 1": {
name: {
"aaa": 1,
},
blue: {
},
green: {
},
black: {
},
yellow: {
}
},
"item 2": {
name: {
"aaa 5": 1,
"bbb 6": 2,
"ccc 7": 3
},
blue: {
},
green: {
},
black: {
},
yellow: {
}
}
}
}
I would like get the keys from this map object. 我想从此地图对象获取密钥。
I'm trying this console.log(Object.keys(buildConfiguration)); 我正在尝试这个console.log(Object.keys(buildConfiguration));
but return 0 itens. 但返回0 itens。
Could please help me? 能帮我吗?
You need to call that function like buildConfiguration()
and you're done 您需要调用诸如
buildConfiguration()
类的函数,然后完成
function buildConfiguration(){ return { "Item 1": { name: { "aaa": 1, }, blue: { }, green: { }, black: { }, yellow: { } }, "item 2": { name: { "aaa 5": 1, "bbb 6": 2, "ccc 7": 3 }, blue: { }, green: { }, black: { }, yellow: { } } } } console.log(Object.keys(buildConfiguration()))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.