This is a very early stage 0 exploration to add enums to Javascript, as a syntatic simplication over a common pattern to define enumerations.
Enums come up often in code bases (TODO: try to estimate a number) and it is easy to get it incorrectly. Specifically, it is easy to forget:
- to
Object.freeze
the object - to declare it as a
const
which avoids having the symbol redefined
With this in mind, we propose a nem keyword to javascript, say enum
which de-sugars to the following: