I'm writing code to set up a lookup structure in Javascript
var g_Codes = {
"Type1": {
"U.S.": "US1",
"Asia": "AS1",
"Europe": "EU1"
},
"Type2": {
"U.S.": "X2",
"Asia": "X2",
"Europe": "X2"
},
"Type3": {
"U.S.": "X3",
"Asia": "X3",
"Europe": "X3"
},
"Type4": {
// Does not exist yet
}
};
So you can loop over this and get the code out by cross-referencing type & region.
However, I'd like to make it so I can do this:
var US_REGION = "U.S.";
var AS_REGION = "Asia";
var EU_REGION = "Europe";
var g_Codes = {
"Type1": {
US_REGION: "US1",
AS_REGION: "AS1",
EU_REGION: "EU1"
},
"Type2": {
US_REGION: "X2",
AS_REGION: "X2",
EU_REGION: "X2"
},
"Type3": {
US_REGION: "X3",
AS_REGION: "X3",
EU_REGION: "X3"
},
"Type4": {
// Does not exist yet
}
};
and make it easier to change the standard region names.
If I try this:
for(let focus in g_Codes) {
print(focus);
}
The first gives me "U.S.", "Asia", etc, while the second gives "US_REGION", "AS_REGION"
How can I use the variables, but keep the simplicity of looping over g_Codes?
let, only FireFox supports it: en.wikipedia.org/wiki/JavaScript#Versions