我有一个简单的javascript地图,其中不包含字段的标识符。我可以遍历地图,但无法获得没有字段标识符的值。
var processStatusTypes = {
1:'ClaimProcess Status 1',
2:'ClaimProcess Status 2',
3:'ClaimProcess Status 3',
4:'ClaimProcess Status 4',
5:'ClaimProcess Status 5',
6:'ClaimProcess Status 6',
7:'ClaimProcess Status 7'
};
for (var index in processStatusTypes) {
console.log(processStatusTypes[index][0]);
console.log(processStatusTypes[index][1]);
}
我知道这应该很简单,但我找不到解决方案。任何帮助,将不胜感激。感谢
答案 0 :(得分:1)
您正在寻找Object.keys
var processStatusTypes = {
1:'ClaimProcess Status 1',
2:'ClaimProcess Status 2',
3:'ClaimProcess Status 3',
4:'ClaimProcess Status 4',
5:'ClaimProcess Status 5',
6:'ClaimProcess Status 6',
7:'ClaimProcess Status 7'
};
var keys = Object.keys(processStatusTypes);
for (var i = 0;i<keys.length;i++) {
console.log(keys[i], processStatusTypes[keys[i]]);
}
&#13;