TypeScript · Types and shapes
enums
Named constants. Prefer union literals for new code because enums add runtime objects.
Syntax
enum Role { Admin, Learner }Example
Example
enum Role {
Admin = "admin",
Learner = "learner",
}
const role: Role = Role.Admin;More in this group
Learn this in the course
Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.