Non-number values for enum in Typescript
· ☕ 1 min read
Use non-numbers in Typescript enums.
enums have the following typical definition and usage -
1 2 3 4 5 6 7 8 9 enum Colors { red, blue, green } console.log(Colors[1]); // blue Or, the numbers can be explicitly specified..
1 2 3 4 5 6 7 8 9 10 11 12 enum Colors { red = 1, blue = 2, green = 3 } console.