Files
2nd/10_Wiki/Topic_JavaScript/JavaScript_Control_Flow.md
T
koriweb 9609c04755 docs(10_Wiki): W3Schools 위키화 — HTML/CSS/JavaScript(core)
W3Schools 튜토리얼을 P-Reinforce v3.1 포맷으로 위키화(영어 본문, 한/영 섹션 헤더).
- Topic_HTML: 59문서 (튜토리얼+예제, 레퍼런스/메타 제외)
- Topic_CSS: 190문서 (메인 + Advanced/Flexbox/Grid/RWD 전체)
- Topic_JavaScript: 120문서 (코어 언어; Temporal/DOM상세/BOM/WebAPI/AJAX/jQuery/Graphics 등은 후속)
각 폴더 00_INDEX.md(MOC) 포함. 코드 verbatim, 미확인분은 "Not found in source" 표기.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 19:21:18 +09:00

5.6 KiB

id, title, category, status, verification_status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, created_at, updated_at, review_reason, merge_history, tags, raw_sources, applied_in, github_commit
id title category status verification_status canonical_id aliases duplicate_of source_trust_level confidence_score created_at updated_at review_reason merge_history tags raw_sources applied_in github_commit
javascript-control-flow JavaScript Control Flow Frontend draft conceptual
control flow
program flow
execution order
JS control flow
conditional flow
B 0.88 2026-06-23 2026-06-23
javascript
js
web
frontend
w3schools
control-flow
loops
conditions
https://www.w3schools.com/js/js_control_flow.asp

JavaScript Control Flow

🎯 한 줄 통찰 (One-line insight)

Control flow is the order in which statements are executed; by default JavaScript runs top-to-bottom and left-to-right on a single thread, and conditions, loops, jumps, and functions are how you alter that order. [S1]

🧠 핵심 개념 (Core concepts)

  • Control flow = order of execution — control flow is the order in which statements are executed in a program. [S1]
  • Default flow is sequential — by default JavaScript executes code sequentially from top to bottom and left to right. [S1]
  • Conditional flow — conditions allow decision-making using if, if...else, switch, and the ternary (? :) operators. [S1]
  • Loops repeat code — loops enable code to run multiple times using for, while, or do...while structures. [S1]
  • Jump statements alter flow abruptly — using break, continue, return, and throw. [S1]
  • Functions are callable, reusable blocks — functions run when they are called. [S1]
  • Single-threaded — JavaScript runs on a single thread; it can only do one thing at a time, so every task waits for the completion of previous tasks. [S1]

🧩 추출된 패턴 (Extracted patterns)

  • Branch on a condition — assign a default value, then override it inside if/else based on a test (e.g. age >= 18). [S1]
  • Repeat with a counted loop — drive repetition with a for loop counter and accumulate output. [S1]
  • Early exit from a loop — combine a loop with a break inside an if to stop early. [S1]
  • Encapsulate logic in a function — wrap reusable computation in a function that returns a value. [S1]

📖 세부 내용 (Details)

JavaScript Control Flow Control flow is the order in which statements are executed in a program. By default, JavaScript executes code sequentially from top to bottom and left to right. Control flow statements enable developers to alter this sequence based on conditions, loops, or keywords. [S1]

Default Flow Default flow runs code sequentially from top to bottom and left to right. [S1]

let x = 5;
let y = 6;
let z = x + y;

Conditional Control Flow Conditions allow decision-making using if, if...else, switch, and ternary (? :) operators. [S1]

let text = "Unknown";

if (age >= 18) {
  text = "Adult";
} else {
  text = "Minor";
}

Loops (Repetition Control Flow) Loops enable code to run multiple times using for, while, or do...while structures. [S1]

for (let i = 0; i < 5; i++) {
  text += "The number is " + i + "<br>";
}

Jump Statements Jump statements alter flow abruptly using break, continue, return, and throw. [S1]

for (let i = 0; i < 10; i++) {
  if (i === 3) { break; }
  text += "The number is " + i + "<br>";
}

Function Flow Functions are callable and reusable code blocks. Functions will run when they are called. [S1]

function myFunction(p1, p2) {
  return p1 * p2;
}

JavaScript Is Single-Threaded JavaScript runs on a single thread. It can only do one thing at a time. Every task must wait for completion of previous tasks, potentially freezing applications during slow operations. Asynchronous programming is covered in the advanced section. [S1]

🛠️ 적용 사례 (Applied in summary)

The page's own snippets are the canonical applied examples — sequential assignment, an if/else age check, a counted for loop, an early break, and a multiplying function. No external project/commit applications found in the source.

💻 코드 패턴 (Code patterns)

Conditional branch:

if (age >= 18) {
  text = "Adult";
} else {
  text = "Minor";
}

Counted loop with early exit:

for (let i = 0; i < 10; i++) {
  if (i === 3) { break; }
  text += "The number is " + i + "<br>";
}

Reusable function:

function myFunction(p1, p2) {
  return p1 * p2;
}

⚖️ 모순 및 업데이트 (Contradictions & updates)

No contradictions found in the source.

검증 상태 및 신뢰도

  • 상태: draft
  • 검증 단계: conceptual (실제 적용 사례 발견 시 applied/validated로 승격 가능)
  • 출처 신뢰도: B (W3Schools — widely used educational reference, not a primary standards body)
  • 신뢰 점수: 0.88
  • 중복 검사 결과: 신규 생성 (New discovery)

🔗 지식 그래프 (Knowledge Graph)

📚 출처 (Sources)

📝 변경 이력 (Change history)

  • 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript Control Flow" page (Astra wiki-curation, P-Reinforce v3.1 format).