Enumerations
suggest changeRemarks
In computer programming, an enumerated type (also called enumeration or enum [..]) is a data type consisting of a set of named values called elements, members or enumerators of the type. The enumerator names are usually identifiers that behave as constants in the language. A variable that has been declared as having an enumerated type can be assigned any of the enumerators as a value.
JavaScript is dynamically typed: variables are not declared with a type, and the language has no native enum type. The examples here simulate enumerators, with the trade-offs of each approach.
Enum definition using Object.freeze
Implementing enums using symbols
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents