Basically, a switch
statement is a flow with three lanes, where one lane it the outer program flow, a check lane and a case lane.
A change of a lane happens with a case
statement, which yields true
with a strict check of the expression of the switch
statement and the value of the case
clause, then you go to the case lane and stays as long as you not reach either break
or the end of the switch
statement.
As long as you are still in the check lane, any break
statement between other checks or the end does not have any effect.
out lane lane
code side check case comment
--------------------- ----- ----- ---- -------------------------------------------------
v
switch (x) { v >>> v
case 0: ? >>> v if case is true, change lane
case 1: ? >>> v if case is true, change lane
doThis(); v v
case 2: ? >>> v if case is true, change lane
doSomethingElse(); v v
break; v <<<<<<<<<< . break statement, back to program flow
default: v ? >>> v change lane if value is not in other case clauses
v v
} v <<< . end of switch
v
I'm trying to create a webview app with jquery that calculate GPA and I've created two buttons one of them for adding new elements and the other one to remove the elements and I'm trying to add more ...
I'm trying to create a webview app with jquery that calculate GPA and I've created two buttons one of them for adding new elements and the other one to remove the elements and I'm trying to add more ...
Consider this code. It is a gross simplification of the program I am writing. let numberOne; let numberTwo; function assignNumbers() { numberOne = Math.random()*10 numberTwo = Math.random()*10 } ...
Consider this code. It is a gross simplification of the program I am writing. let numberOne; let numberTwo; function assignNumbers() { numberOne = Math.random()*10 numberTwo = Math.random()*10 } ...
I have a table in my html document that is styled with css. When I hard code the table rows and cells in html, the styling is working as desired. For example when I hover the mouse over a row, the ...
I have a table in my html document that is styled with css. When I hard code the table rows and cells in html, the styling is working as desired. For example when I hover the mouse over a row, the ...
I have the following array: let arr = [ {"id": 123, "lastUpdate": 1543229793}, {"id": 456, "lastUpdate": 1545269320}, {"id": 123, "lastUpdate": 1552184795} ] I need to filter the array ...
I have the following array: let arr = [ {"id": 123, "lastUpdate": 1543229793}, {"id": 456, "lastUpdate": 1545269320}, {"id": 123, "lastUpdate": 1552184795} ] I need to filter the array ...