Last updated 2 years ago
Was this helpful?
⟩ ⟩ ⟩ ⟩ switch
(statement)
switch (<expr>) { case <value1> : <statements> case <value2> : <statements> default : <statements> }
not block:
object literal / class / switch ( no block scope)
function's is different from a block scope
📗
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 (===).
(expr)
switch statement uses punctuators , , .
JavaScript: The Definitive Guide ⟩ 5.3.3 switch
⟩ ⟩ ⭐️
()
{}
: