--- id: javascript-break title: "JavaScript Break" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["break statement", "JS break", "labeled break", "break continue", "break label"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.89 created_at: 2026-06-23 updated_at: 2026-06-23 review_reason: "" merge_history: [] tags: ["javascript", "js", "web", "frontend", "w3schools", "break", "loops", "labels", "control-flow"] raw_sources: ["https://www.w3schools.com/js/js_break.asp"] applied_in: [] github_commit: "" --- # [[JavaScript Break]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) The `break` statement jumps out of a loop or switch; with a label, it can jump out of any code block. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **Jumps out** β€” the `break` statement "jumps out" of loops and switches, terminating execution immediately. [S1] - **Break in loops** β€” when `break` is reached in a loop, the loop terminates immediately and control transfers to the statements following the loop; no further iterations execute. [S1] - **Break in a switch** β€” in a `switch`, `break` exits the block after a matching case executes; without it, execution falls through to subsequent cases. [S1] - **Labels** β€” a label is an identifier followed by a colon (`labelname: statement;`), and `break labelname;` jumps out of the labeled block. [S1] - **Only break and continue jump out of a block** β€” `break` and `continue` are the only JavaScript statements that can jump out of a code block; without a label, `break` only exits loops or switches. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Early exit on a sentinel** β€” test a condition inside the loop and `break` when it is met. [S1] - **Labeled break for nested loops** β€” name outer/inner loops and `break loop1;` / `break loop2;` to control exactly which loop terminates. [S1] - **Break out of a plain code block** β€” label a `{ ... }` block and `break label;` to skip the remaining statements. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) **The break statement** [S1] The `break` statement "jumps out" of loops and switches, terminating execution of a loop or switch statement immediately. **Break in loops** [S1] When `break` is encountered in a loop, the loop terminates immediately and control transfers to the statements following the loop. No further iterations execute. ```javascript for (let i = 0; i < 10; i++) { if (i === 3) { break; } text += "The number is " + i + "
"; } ``` **Break in a switch** [S1] In a `switch` statement, `break` exits the block after a matching case executes. Without it, execution "falls through" to subsequent cases. ```javascript switch (new Date().getDay()) { case 0: day = "Sunday"; break; case 1: day = "Monday"; break; case 2: day = "Tuesday"; break; case 3: day = "Wednesday"; break; case 4: day = "Thursday"; break; case 5: day = "Friday"; break; case 6: day = "Saturday"; } ``` **JavaScript labels** [S1] A label is an identifier followed by a colon: `labelname: statement;`. A labeled break uses the syntax `break labelname;`. **Break to loop1** [S1] ```javascript let text = ""; loop1: for (let j = 1; j < 5; j++) { loop2: for (let i = 1; i < 5; i++) { if (i === 3) { break loop1; } text += i; } } ``` **Break to loop2** [S1] ```javascript let text = ""; loop1: for (let j = 1; j < 5; j++) { loop2: for (let i = 1; i < 5; i++) { if (i === 3) { break loop2; } text += i; } } ``` **Break out of a code block** [S1] ```javascript const cars = ["BMW", "Volvo", "Saab", "Ford"]; list: { text += cars[0] + "
"; text += cars[1] + "
"; break list; text += cars[2] + "
"; text += cars[3] + "
"; } ``` **Note** [S1] `break` and `continue` are the only JavaScript statements that can "jump out of" a code block. Without a label, `break` only exits loops or switches; with a label, it exits any code block. ## πŸ› οΈ 적용 사둀 (Applied in summary) The page's own snippets are the canonical applied examples β€” early-exiting a `for` loop at `i === 3`, exiting `switch` cases, labeled breaks targeting `loop1`/`loop2`, and breaking out of a labeled `list:` block. No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Early exit from a loop: ```javascript for (let i = 0; i < 10; i++) { if (i === 3) { break; } text += "The number is " + i + "
"; } ``` Labeled break out of an outer loop: ```javascript loop1: for (let j = 1; j < 5; j++) { loop2: for (let i = 1; i < 5; i++) { if (i === 3) { break loop1; } text += i; } } ``` Break out of a labeled code block: ```javascript list: { text += cars[0] + "
"; break list; text += cars[2] + "
"; } ``` ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) No contradictions found in the source. ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual (μ‹€μ œ 적용 사둀 발견 μ‹œ applied/validated둜 승격 κ°€λŠ₯) - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.89 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[JavaScript Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[JavaScript Loops]], [[JavaScript For Loop]], [[JavaScript While Loop]], [[JavaScript Switch]] - **μ°Έμ‘° λ§₯락:** Used to terminate loops/switches early; paired with `continue` as the only block-jumping statements. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” JavaScript Break β€” https://www.w3schools.com/js/js_break.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript Break" page (Astra wiki-curation, P-Reinforce v3.1 format).