# Numeric Enums — TypeScript

Source: https://www.geekswithgeeks.com/en/typescript/ts-numeric-enums

> A named set of numeric constants.

## A numeric enum

`enum` groups related constants under one name, giving each member a numeric value.

```typescript
enum Status {
  Pending,   // 0
  Active,    // 1
  Closed,    // 2
}

let s: Status = Status.Active;
console.log(s);          // 1
console.log(Status[1]);  // "Active"
```

## Auto-increment & custom start

Values default to `0, 1, 2, ...` in order. Set the first explicitly — `Pending = 1` — and the rest continue from there.

## Reverse mapping

Numeric enums support a reverse lookup — `Status[1]` gives `"Active"` — string enums don't have this.

**Quiz:** In `enum Status { Pending, Active, Closed }`, what is `Status.Closed`?

- [ ] 0
- [ ] 1
- [x] 2

*Answer:* 2. Members default to 0, 1, 2 in declaration order, so Closed is 2.
