Enums and as const
An enum names a set of related constants. A plain union of literals often does the same with less code.
Exampletypescript
as const makes values read only and exact. keyof typeof Colors builds the union "red" | "green" from the object.
Quick check
What does `as const` do to an object?
Your turn: write the code
Declare enum Color { Red, Green, Blue }. Print Color.Green, then the name for the value 2 (Color[2]).
Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.
Tip: use the left and right arrow keys to move between lessons.