I want to use a so called "enum" object as dictionary key,(actually,it is also a dictionary AFAIK), in JavaScript.
This doesn't work:
var State ={DEFAULT:0,ACTIVE:1 ,INACTIVE:2,ALERT:3};
var statesDict = {
State.ACTIVE : {color:0x00ff00}
State.INACTIVE: {color:0x000000}
};
while this one does:
var State ={DEFAULT:0,ACTIVE:1 ,INACTIVE:2,ALERT:3};
var statesDict = {
1: {color:0x00ff00}
2: {color:0x000000}
};
Why? Isn't the State.{prop name}
supposed to be replaced by its value?