Search⌘ K

Enumerations

Explore enumerations and their role in front-end applications using plain JavaScript. Understand simple enumerations, code lists, and record enumerations, and learn how to implement these data types for attributes with fixed string values. Gain insights on best practices for naming and using enumeration literals to improve code readability and maintainability.

Simple enumerations

In all application domains, there are string-valued attributes with a fixed list of possible string values. These attributes are called enumeration attributes, and the fixed value lists defining their possible string values are called enumerations. For instance, when we have to manage data about people, we often need to include information about their gender. The possible values of a gender attribute may be restricted to one of the enumeration labels “man”, “woman”, and “other”, or to one of the ...