Suggest an editImprove this articleRefine the answer for “break in switch”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)**`break` in `switch`** stops execution of the block right after the matching `case`, so the program does not continue into the following branches. **Key point:** without `break`, the code "falls through" into the next `case`, all the way to the end of the block or the nearest `break`.Shown above the full answer for quick recall.Answer (EN)ImageThe `break` statement in a `switch` construct is used to **interrupt execution** of the `switch` block, so the program **does not continue** into the following `case`s after a match is found. --- ## Example without `break` ```javascript const day = 2; switch (day) { case 1: console.log('Monday'); case 2: console.log('Tuesday'); case 3: console.log('Wednesday'); default: console.log('Unknown day'); } ``` Result: ```javascript Tuesday Wednesday Unknown day ``` > After matching `case 2`, the code **did not stop**, > it "fell through" downward, running all the following blocks. > This behavior is called **"fall-through"**. --- ## Example with `break` ```javascript const day = 2; switch (day) { case 1: console.log('Monday'); break; case 2: console.log('Tuesday'); break; case 3: console.log('Wednesday'); break; default: console.log('Unknown day'); } ``` Result: ```javascript Tuesday ``` > After running `console.log('Tuesday')`, > the `break` statement **exited the switch**, > and the remaining `case`s were skipped. --- ## When `break` is not needed If you **deliberately want to combine several cases**: ```javascript const day = 6; switch (day) { case 6: case 7: console.log('Day off'); break; default: console.log('Workday'); } ``` Result: ```javascript Day off ``` > Here, "falling through" is used **intentionally**, > so both branches run the same code. --- ## Summary | Situation | What `break` does | |---|---| | After a `case` match | Stops execution of the `switch` | | If `break` is missing | The code "falls through" into the next `case` | | In `default` | Usually a trailing `break` is added, but it can be omitted | | Can be used in other loops | Stops `for`, `while`, `do...while` | --- ## In short - `break` in `switch` stops execution after the matching `case`. - Without it, **all the following case**s run until the end or until a `break`. - It is used to **avoid "falling through"**.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.