0

What happend if I didn't use break in switch's case?

1st Jul 2016, 3:48 PM
buremu
2 Answers
0
If you don't use break then all the cases will executes until the next break statement found
1st Jul 2016, 4:43 PM
Gaurav Sharma
Gaurav Sharma - avatar
0
to add to the previous answer if u dont add break at all it would use the default e.g switch (myVar) { case ("hi") : document.write("hi to you too"); /*no break here*/ case("hello"): document.write("hello to u too"); /*no break here either*/ default: document.write("bye"); } and say myVar is hi or hello, itd display bye as ther are no breaks. I hope i helped
1st Jul 2016, 10:23 PM
aiden
aiden - avatar