Enums in Javascript with ES6
I’m rebuilding an old Java project in Javascript, and realized that there’s no good way to do enums in JS. The best I can come up with is: const Colors = { RED: Symbol(“red”), BLUE: Symbol(“blue”), GREEN: Symbol(“green”) }; Object.freeze(Colors); The const keeps Colors from being reassigned, and freezing it prevents mutating the keys and … Read more