Reading the "recommended way" of dealing with ENUM Type in Javascript, I am still uncertain because I can compare the value with a forged value, while I should compare only to a "enum" type value:
var DaysEnum = {"monday":1, "tuesday":2, "wednesday":3, ...}
Object.freeze(DaysEnum)
switch( day ){
case "monday":
return "Hello"
case "tuesday":
return "Hi"
case "blahblahday":
return "No"
}
The strings I made the switch to compare against ("monday", "tuesday", "blahblahday") are totally free from my "enum type: DaysEnum", can be provided by the user and this could lead to some subtle errors not spotted by the interpreter (like typos).
Is there a way to have/lock unique index values of the Enum object?