Javascript Switch Case

This Javascript Switch Case acts like a multiple if / else if / else chain. Checks a value against a list of cases, and executes the first case that is true. If no matching case found, it executes the default case. The break(optional) statements with case indicate to the interpreter to end the particular case.

Syntax

Javascript Switch Case Example 1

If forget a break which is optional than script will run from the case where condition is met, and will run the case after that regardless if condition was met.

Javascript Switch Case Example 2