box*_*pah 3 javascript break while-loop switch-statement
关于C ++中的这个问题,存在类似的问题,但是我在这里使用JavaScript。我基本上和其他帖子中的OP处于相同的情况。
var input = prompt();
while(true) {
switch(input) {
case 'hi':
break;
case 'bye':
//I want to break out of the switch and the loop here
break;
}
/*Other code*/
}
Run Code Online (Sandbox Code Playgroud)
反正有这样做吗?
我/*Other code*/在代码也应该中断的部分中也有多个开关。
您可以在js中使用break语句使用标签
var input = prompt();
outside:
while(true) {
switch(input) {
case 'hi':
break;
case 'bye':
//I want to break out of the switch and the loop here
break outside;
}
/*Other code*/
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1770 次 |
| 最近记录: |