Lesson 15 / 26
String Enums
Enums whose members hold readable string values.
A string enum
Every member must be given an explicit string — nothing is auto-generated, which keeps logs and debugging readable.
enum Direction {
Up = "UP",
Down = "DOWN",
Left = "LEFT",
Right = "RIGHT",
}
console.log(Direction.Up); // "UP"Enums vs literal unions
A string literal union ("UP" | "DOWN") needs no import and compiles to nothing extra. A string enum is a real object at runtime — useful when you need to iterate members or need a namespace.