capypad
0 day streak
typescript / beginner
Snippet

Numeric Enums

Numeric enums store members as numbers. By default, they start at 0 and increment automatically for each subsequent member.

snippet.ts
typescript
1
2
3
4
5
6
7
enum Status {
New,
Active,
Closed
}
 
const currentStatus = Status.New;
Breakdown
1
enum Status
Defines a numeric enumeration for tracking states.
2
New
The first member, which automatically gets the value 0.
3
Active
The second member, which automatically increments to 1.