enum Direction {
    Up = "UP",
    Down = "DOWN",
    Left = "LEFT",
    Right = "RIGHT"
}

console.log(Direction.Up); // Output: UP
Bash

Explanation:

  • This program defines an enum called Direction, representing various directional constants.
  • Enums provide a way to give friendly names to sets of numeric or string values.
Resize text
Scroll to Top