case
statements found JS-0064That’s all we can say right now.
If the fallthrough is intentional in the code, there is no way to indicate this intent in the language.
It's considered a best practice to always indicate when a fallthrough is intentional using a comment which matches the /falls?\s?through/i
regular expression.
switch(foo) {
case 1: doSomething();
case 2: doSomethingElse();
}
switch(foo) {
case 1:
doSomething();
break;
case 2:
doSomethingElse();
}
function bar(foo) {
switch(foo) {
case 1:
doSomething();
return;
case 2:
doSomething();
}
}
switch(foo) {
case 1:
doSomething();
throw new Error("Boo!");
case 2:
doSomething();
}
switch(foo) {
case 1:
case 2:
doSomething();
}
switch(foo) {
case 1:
doSomething();
// falls through
case 2:
doSomething();
}