Switch Case Javascript
This will stop the execution of inside the block.
Switch case javascript. Consider a situation when we want to test a variable for hundred different values and based on the test we want to execute some task. It is not necessary to break the last case in a switch block. Each case in the switch statement executes the corresponding statement statement 1 statement 2 if the expression equals the value value 1 value 2.
In some cases using the switch case statement is seen to be more convenient over if else statements. The break keyword causes the execution to jump out of the switch statement. When javascript reaches a break keyword it breaks out of the switch block.
The switch statement evaluates an expression matching the expression s value to a case clause and executes statements associated with that case as well as statements in cases that follow the matching case. If you omit the break keyword the code execution falls through the original case into the next one. The switch case statement in javascript is also used for decision making purposes.