Javatpoint Logo
Javatpoint Logo

TypeScript Switch Statement

TypeScript switch statement executes one statement from multiple conditions. It evaluates an expression based on its value that could be boolean, number, byte, short, int, long, enum type, string, etc. A switch statement has one block of code corresponding to each value. When the match is found, the corresponding block will be executed. A switch statement is work like if-else-if ladder statement.

The following points must be remembered in a switch statement:

  • There can be N number of cases inside a switch statement.
  • The case values must be unique.
  • The case values must be constant.
  • Each case statement has a break statement at the end of the code. The break statement is optional.
  • The switch statement has a default block which is written at the end. The default statement is optional.


TypeScript Switch Statement



a+b is 5.

Example with String


Marks [ >= 80 and <90 ]

TypeScript Switch Statement is fall-through

The TypeScript switch statement is fall-through. It means if a break statement is not present, then it executes all statements after the first match case.



Not in 10, 20 or 30

Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA