Enums define a set of named constants. Numeric enums auto-increment.
Getting Started
What is TypeScript?
Basic Types
Types & Interfaces
Async TypeScript
Promises & Async/Await
TypeScript
Intermediate
FREE
Enums
Lesson 2 of 17
Intermediate
Interactive
Syntax
TYPESCRIPT
enum Direction { Up, Down, Left, Right } enum Status { Active = "ACTIVE", Inactive = "INACTIVE" }
TypeScript Enums
TYPESCRIPT
enum Status { Active = "ACTIVE", Inactive = "INACTIVE", Pending = "PENDING" } enum Color { Red = 0, Green = 1, Blue = 2 } let userStatus: Status = Status.Active; console.log(userStatus); let primary: Color = Color.Red; console.log(Color[primary]);
Practice
1
Exercise
Practice this concept.
Answer
Write the code as shown above.
Quick Quiz
1
What did you learn?
This covers the basics.
Interview Questions
It is a fundamental TypeScript feature.