it is a way of defining group of named constant. it is used for improve code readability .
Syntax:
1 2 3 4 5 |
enum EnumName { Constant1, Constant2, ... } |
example code:
1 2 3 4 5 6 7 8 9 10 |
enum Color { Red, Green, Blue } let myColor: Color = Color.Green; console.log(myColor) |
output would be : 1
By default, enums are assigned incremental numeric values starting from 0.