Enumerated data types (enums) are a set of numeric values with more friendly names. It's an addition on top of JavaScript that TypeScript offers. code example
Example 1: typescript enum to string
enum AnEnum {
One = 1,
Two = 2
}
let stringOne = AnEnum[1]; // "One"
let stringTwo = AnEnum[AnEnum.Two]; // "Two"
Example 2: enum to number typescript
enum UserResponse {
No = 0,
Yes = 1,
}
console.log(UserResponse.Yes) //logs : 1