capypad
0 day streak
typescript / beginner
Snippet

String Enums

String enums allow you to define a set of named constants with string values. They provide better readability and easier debugging compared to numeric enums because the values are descriptive.

snippet.ts
typescript
1
2
3
4
5
enum LogLevel {
Info = 'INFO',
Warn = 'WARN',
Error = 'ERROR'
}
Breakdown
1
Info = 'INFO'
Maps the name 'Info' to the specific string value 'INFO'.