🔀switch

JSstatementcontrol flowbranch ⟩ switch

(statement)

switch (<expr>) {
    case <value1> : <statements>
    case <value2> : <statements>
    default       : <statements>
}

labeled statement is needed when you want to break out of a statement that is not the nearest enclosing loop / switch.

the comparison between switch (expr) and a case clause is done by strict equality (===).

Last updated