+ 1
If we don't use break, how it execute!!
6 Réponses
+ 4
All case will be executed after matched case until a break is detected.
+ 1
if you don't use the break keyword, it executes the next code block without checking the case.
Example:
x = 5;
switch (x) {
case 5:
console.log("5");
case 6:
console.log("6");
break;
}
//Output: 5 6
+ 1
No, it will execute no matter what
x = 1;
switch (x) {
case 1:
console.log(1);
case 2:
console.log(2);
case 3:
console.log(3);
case 4:
console.log(4);
}
//Output: 1 2 3 4
0
Airree it's not the next code. For ex if the next code block is false too. is it execute???
0
Yes, it will because it doesn't check the condition until it reaches a break
0
But my question said that don't use the break.