Skip to main content
D
TypeScript
TypeScript Enums

TypeScript Enums

Enums group related constant values together.

Read Time
5 min read
Difficulty
Beginner
Last Updated
Jun 15, 2026
Version
v1.0.0

Introduction

An Enum (short for Enumeration) is a special feature that creates a collection of related, unchangeable values. Developers use them for things that have a specific set of options, like the days of the week, or user permission levels.

Example

Example
1/* this creates an enum */
2enum UserRole {
3  Admin = "ADMIN",
4  Editor = "EDITOR",
5  Viewer = "VIEWER"
6}
7
8const myRole: UserRole = UserRole.Admin;

Key Points

  • Enums can be numeric (0, 1, 2) or string-based ("A", "B", "C").
  • String enums are usually easier to debug.
  • They prevent spelling mistakes when typing out specific options.
  • Unlike interfaces, Enums compile into actual JavaScript code.

Up Next

Continue your journey with the next topic.

Go to TS Tuples