如何在Javascript中执行此操作?
switch(c){
case 'a':
//do something, condition does not match so go to default case
//don't break in here, and don't allow fall through to other cases.
case 'b':
//..
case 'c':
//..
case '_':
//...
default:
//
break;
}
这几乎是Jumping from one case to the default case in switch statement的副本,但是没有javascript的解决方案,所以我必须添加这个新帖子。
答案 0 :(得分:1)
根据您的使用情况,可能有效的另一个选项是将default
案例移出交换机。
switch(c){
case 'a':
//do something, condition does not match so go to default case
//don't break in here, and don't allow fall through to other cases.
case 'b':
//..
case 'c':
//..
case '_':
//...
}
// Do the `default/finally` here instead