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>
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-for-loop | JavaScript For Loop | Frontend | draft | conceptual |
|
B | 0.89 | 2026-06-23 | 2026-06-23 |
|
|
JavaScript For Loop
🎯 한 줄 통찰 (One-line insight)
The for statement creates a loop with three optional expressions — initialize, test, update — letting a code block run a controlled number of times. [S1]
🧠 핵심 개념 (Core concepts)
- Three optional expressions — the
forstatement creates a loop with three optional expressions. [S1] - exp1 — initializer — sets a variable before the loop starts (
let i = 0), and can be omitted if initialization happens beforehand. [S1] - exp2 — condition — defines the condition for the loop to run; it is optional, but if omitted you must
breakinside the loop or it runs forever. [S1] - exp3 — update — increases a value (
i++) after the code block executes; it is optional and can do other operations. [S1] - Loop scope matters —
letscopes the counter to the loop;varredeclares the outer variable. [S1]
🧩 추출된 패턴 (Extracted patterns)
- Index-driven array traversal — cache
cars.lengthonce, then iterateifrom 0 to that length. [S1] - Omit-and-supply elsewhere — any of the three expressions can be moved out of the
for(...)header (initialize before, update inside the body). [S1] - Prefer
letfor the counter — keepsiprivate to the loop. [S1]
📖 세부 내용 (Details)
The for statement [S1]
The for statement creates a loop with 3 optional expressions, allowing the code block to execute multiple times.
- exp1 sets a variable before the loop starts (
let i = 0). - exp2 defines the condition for the loop to run (
imust be less than 5). - exp3 increases a value (
i++) after the code block has been executed.
The first expression can be omitted if initialization occurs before the loop. The second expression is optional but requires a break statement inside the loop to prevent infinite execution. The third expression is optional and can perform various operations like negative increment or custom calculations.
Basic for loop [S1]
for (let i = 0; i < 5; i++) {
text += "The number is " + i + "<br>";
}
Iterating through an array [S1]
const cars = ["BMW", "Volvo", "Saab", "Ford"];
let len = cars.length;
let text = "";
for (let i = 0; i < len; i++) {
text += cars[i];
}
Omitting exp1 [S1]
const cars = ["BMW", "Volvo", "Saab", "Ford"];
let len = cars.length;
let i = 2;
let text = "";
for (; i < len; i++) {
text += cars[i] + "<br>";
}
Omitting exp3 [S1]
const cars = ["BMW", "Volvo", "Saab", "Ford"];
let len = cars.length;
let i = 0;
let text = "";
for (; i < len; ) {
text += cars[i] + "<br>";
i++;
}
Loop scope [S1]
Using var in a loop, the loop variable redeclares the outer variable:
var i = 5;
for (var i = 0; i < 10; i++) {
// some code
}
// Here i is 10
Using let in a loop, the variable is scoped only within the loop. When let is used to declare the i variable, the i variable will only be visible within the loop:
let i = 5;
for (let i = 0; i < 10; i++) {
// some code
}
// Here i is 5
🛠️ 적용 사례 (Applied in summary)
The page's own snippets are the canonical applied examples — counting 0–4, traversing a cars array (with len cached), and demonstrating exp1/exp3 omission and let/var scoping. No external project/commit applications found in the source.
💻 코드 패턴 (Code patterns)
Standard counted loop:
for (let i = 0; i < 5; i++) {
text += "The number is " + i + "<br>";
}
Array traversal with cached length:
const cars = ["BMW", "Volvo", "Saab", "Ford"];
let len = cars.length;
for (let i = 0; i < len; i++) {
text += cars[i];
}
⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
letvsvarfor the counter —letkeepsivisible only inside the loop (iis 5 afterward in the example);varleaks/redeclares it to the outer scope (iis 10 afterward). Preferlet. [S1]
⚖️ 모순 및 업데이트 (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 While Loop, JavaScript Break, JavaScript For In
- 참조 맥락: The primary counted-iteration construct; detailed expansion of the
forloop introduced in JavaScript Loops.
📚 출처 (Sources)
- [S1] W3Schools — JavaScript For Loop — https://www.w3schools.com/js/js_loop_for.asp
📝 변경 이력 (Change history)
- 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript For Loop" page (Astra wiki-curation, P-Reinforce v3.1 format).