에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게 [공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류. 문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인). - Topic_Programming → Domain_Programming (내부 구조 보존) - Topic_Graphic → Domain_Design - Topic_Business → Domain_Product - Topic_General → Domain_General - _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning), Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing) - 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서) - 빈 폴더 정리 (memory/procedures) - 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
6.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-switch | JavaScript Switch | Frontend | draft | conceptual |
|
B | 0.89 | 2026-06-23 | 2026-06-23 |
|
|
JavaScript Switch
🎯 한 줄 통찰 (One-line insight)
The switch statement selects one of many code blocks to execute by comparing an expression against case values using strict comparison (===). [S1]
🧠 핵심 개념 (Core concepts)
- Selects a code block by condition — based on a condition,
switchselects one or more code blocks to be executed. [S1] breakstops fall-through — when JavaScript reachesbreak, it breaks out of the switch block, preventing unmatched cases from also executing. [S1]defaultis the fallback — thedefaultkeyword specifies a block of code to run if there is no case match; it is optional. [S1]- Strict comparison — switch uses strict comparison (
===); values must match in both value and type. [S1] - First match wins — if multiple cases match a case value, the first case is selected. [S1]
🧩 추출된 패턴 (Extracted patterns)
- Evaluate once, branch many — the switch expression is evaluated once, then its value is compared against each case. [S1]
- Shared code blocks — multiple cases can share a single code block by listing cases back-to-back before the shared code. [S1]
- Default-not-last requires
break— ifdefaultis not the last clause, terminate it withbreakso execution does not fall through. [S1]
📖 세부 내용 (Details)
Switch control flow [S1]
Based on a condition, switch selects one or more code blocks to be executed.
Syntax [S1]
switch(expression) {
case x:
// code block
break;
case y:
// code block
break;
default:
// code block
}
How it works [S1]
The switch expression is evaluated once. The value of the expression is compared with the values of each case. If there is a match, the associated block of code is executed. If there is no match, no execution occurs (unless a default is present).
Example — weekday calculator [S1]
The getDay() method returns the weekday as a number between 0 and 6 (Sunday=0, Monday=1, etc.).
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";
}
The break keyword [S1]
When JavaScript reaches a break keyword, it breaks out of the switch block. This stops the execution inside the switch block and prevents fall-through, where unmatched cases would otherwise also execute.
The default keyword [S1]
The default keyword specifies the code to run if there is no case match.
switch (new Date().getDay()) {
case 6:
text = "Today is Saturday";
break;
case 0:
text = "Today is Sunday";
break;
default:
text = "Looking forward to the Weekend";
}
default not at the end [S1]
When default is not the last clause, terminate it with break.
switch (new Date().getDay()) {
default:
text = "Looking forward to the Weekend";
break;
case 6:
text = "Today is Saturday";
break;
case 0:
text = "Today is Sunday";
}
Common code blocks [S1] Sometimes you will want different switch cases to use the same code; multiple cases can share a code block.
switch (new Date().getDay()) {
case 4:
case 5:
text = "Soon it is Weekend";
break;
case 0:
case 6:
text = "It is Weekend";
break;
default:
text = "Looking forward to the Weekend";
}
Switching details [S1]
If multiple cases match a case value, the first case is selected. If no matching cases are found, the program continues to the default label. If no default label is found, the program continues to the statements after the switch.
Strict comparison [S1]
Switch cases use strict comparison (===). The values must be of the same type to match. A strict comparison can only be true if the operands are of the same type. In this example there will be no match for x, because x is a string and the cases are numbers:
let x = "0";
switch (x) {
case 0:
text = "Off";
break;
case 1:
text = "On";
break;
default:
text = "No value found";
}
🛠️ 적용 사례 (Applied in summary)
The page's own snippets are the canonical applied examples — mapping new Date().getDay() to a weekday name, weekend detection via default, and grouping days with shared code blocks. No external project/commit applications found in the source.
💻 코드 패턴 (Code patterns)
Basic switch with break and default:
switch(expression) {
case x:
// code block
break;
case y:
// code block
break;
default:
// code block
}
Shared code block across cases:
switch (new Date().getDay()) {
case 4:
case 5:
text = "Soon it is Weekend";
break;
case 0:
case 6:
text = "It is Weekend";
break;
default:
text = "Looking forward to the Weekend";
}
⚖️ 모순 및 업데이트 (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 If Else, JavaScript Ternary, JavaScript Break, JavaScript Comparisons
- 참조 맥락: Chosen over long
if...elsechains when branching on the discrete values of a single expression.
📚 출처 (Sources)
- [S1] W3Schools — JavaScript Switch — https://www.w3schools.com/js/js_switch.asp
📝 변경 이력 (Change history)
- 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript Switch" page (Astra wiki-curation, P-Reinforce v3.1 format).