I’m reading Javascript: the Definitive Reference, and it says on page 93:
On rare occasions, it is useful to write code like this that falls
through from one case label to the next, but 99% of the time you
should be very careful to end every case within a switch with a break
statement.
In what situation would you let a switch statement fall through to multiple case statements?
One useful case is when several values should have the same result:
The empty cases will just fall though to the next. In this case there is minimal risk for confusion.
The case that the book author is worried about is when you combine actions, for example where the value
2should have bothaction2andaction3:Forgetting a
breakis such a common mistake, that you should add a comment like above to make it clear that it was intentionally left out.For comparison; in C# you are not allowed to just omit a
breakin aswitch, there you have to use agotoinstead to specify the case where the exection should continue.