In JavaScript, a flow control statement is an instruction to the JavaScript interpreter about what it should do when certain conditions are met. A JavaScript switch case statement looks at the values of one or more expressions and executes one of several blocks of code depending on which expression (or expressions) evaluated to true.
Switch case statements are similar to if else statements in that they provide multiple ways for execution, but unlike if else statements, each block can be labeled with a different number instead of just “else”.
Table of Contents
Syntax
switch (expression) {
case value_1:
statement_1;
break;
case value_2:
statement_2;
break;
case value_3:
statement_3;
break;
default:
default_statement;
}
FlowChart

The switch statement is a control flow construct that allows you to compare an expression with several values and execute different statements based on which one matches. It is very similar to if-else, but it can be used in situations where there are more than two choices.
For example, you may want to select among 4 different messages depending on the day of week or whether it’s Christmas Day or not.
Example
In this example, we will declare a variable named month whose value will represent a month in a year. We will put that variable in switch statement and the output will come on the basis of that value.
Code
var month = 9;
var monthName;
switch (month) {
case 1:
monthName = 'January';
break;
case 2:
monthName = 'February';
break;
case 3:
monthName = 'March';
break;
case 4:
monthName = 'April';
break;
case 5:
monthName = 'May';
break;
case 6:
monthName = 'June';
break;
case 7:
monthName = 'July';
break;
case 8:
monthName = 'August';
break;
case 9:
monthName = 'September';
break;
case 10:
monthName = 'October';
break;
case 11:
monthName = 'November';
break;
case 12:
monthName = 'December';
break;
default:
monthName = 'Invalid month';
}
console.log(monthName);
Output

So, we initialize the month value as 9. It’s returning us the month of September.
Conclusion
Flow control statements are an integral part of programming, and JavaScript is no exception. The switch case statement in particular can be used to help you make decisions based on the value of one or more expressions. If your next project requires a flow control statement, don’t hesitate to use the JavaScript switch case!