Skip to content

Enum

Easy — everyone uses thisGeneral Dev

ELI5 — The Vibe Check

An enum is a named list of options that are all related. Instead of using magic strings like 'red', 'green', 'blue' everywhere, you define a Color enum and use Color.Red. No typos, no guessing what's valid.

Real Talk

An enum (enumeration) defines a set of named constant values. They make code more readable and prevent invalid states by constraining a variable to only the defined members. Most typed languages support them natively.

Show Me The Code

// TypeScript enum
enum Status {
  Pending = "PENDING",
  Active = "ACTIVE",
  Closed = "CLOSED"
}

const orderStatus: Status = Status.Pending;

When You'll Hear This

"Use an enum for the order statuses instead of raw strings." / "The enum has four possible states."

Made with passive-aggressive love by manoga.digital. Powered by Claude.