Reputation: 1104
I have a simple javascript map which does not contain identifiers for the fields. I can iterate through the map but can not obtain the values without the field identifiers.
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]);
}
I know this should be simple but i can not find a solution. Any help would be appreciated. Thanks
Upvotes: 0
Views: 248
Reputation: 136074
You're looking for 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]]);
}
Upvotes: 1