switch statements use expressions, or cases, to control statement execution. Each case holds one possible value and includes the statements to execute when the value matches the expression result. The following table compares the control logic of a switch to an if...else.
JavaScript evaluates the expression in a switch, then compares the expression value to each case until it finds a matching value. The statements in the matching case are executed and the next case is compared. If the matching case ends with a break statement, JavaScript skips the rest of the cases (conserving execution time).