Skip to content

Commit bbf7105

Browse files
committed
enums
1 parent 1e4eede commit bbf7105

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

TS/Basics/enums.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// ENUMS
2+
// Enums stands for Enumerations. Enums are a new data type supported in TypeScript. It is used to define the set of named constants, i.e., a collection of related values. TypeScript supports both numeric and string-based enums.
3+
4+
// This is not a good way to code for restrictive variables
5+
// const AISLE = 0;
6+
// const MIDDLE = 1;
7+
// const WINDOW = 2;
8+
9+
// if (seat === AISLE ){}
10+
11+
12+
// We solve this using ENUMS
13+
enum SeatChoice {
14+
AISLE = "aisle",
15+
MIDDLE = 22,
16+
WINDOW,
17+
FOURTH = 78
18+
}
19+
20+
const seat = SeatChoice.AISLE
21+
// const seat1 = SeatChoice.FOURTH
22+
console.log(seat);

0 commit comments

Comments
 (0)