If multiple cases match a case value, the first matching case is selected.
If no matching cases are found, the program proceeds to the default label.
If there is no default label, the program continues to the statements that follow the switch.
Switch cases utilize strict comparison (===).
The values must be of the same type to match.
A strict comparison can only evaluate to true if the operands are of the same type.
In this example, there will be no match for x.
let x = “0”; switch (x) { case 0: text = “Off”; break; case 1: text = “On”; break; default: text = “No value found”; } |