Enums
Learn how to use enumerations for better code clarity.
1
Enums
Welcome to the next lesson! In this lesson, you’ll learn about enums in TypeScript. Enums allow you to define a set of named constants, making your code more readable and easier to manage. Let’s dive in!

2
What Are Enums?
An enum (short for enumeration) is a data type that allows you to define a set of named constants. Enums are used to group related values together, making your code more organized and less error-prone.
Example: Days of the week can be represented using an enum:
Task: Create an enum for months of the year and log some values.
enum Days {
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
Sunday,
}
console.log(Days.Monday); // Output: 0
console.log(Days.Friday); // Output: 4