BasicSytax
Switch can "fall through" without break --[MDN](A re-introduction to JavaScript (JS tutorial) - JavaScript | MDN (mozilla.org))
situation 1
function eatIt(){ console.log("eat")};
var a = 1
switch (a) {
case 1: // fallthrough
case 2:
eatIt();
break;
default:
doNothing();
}
output will be
eat
situation 2
switch (a) {
case 1:
eatIt();
// fallthrough
case 2:
eatIt();
break;
default:
doNothing();
}
output will be
eat
eat