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>
7.0 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-async-await | JavaScript Async Await | Frontend | draft | conceptual |
|
B | 0.89 | 2026-06-23 | 2026-06-23 |
|
|
JavaScript Async Await
🎯 한 줄 통찰 (One-line insight)
async and await make promises easier by letting you write asynchronous code like normal step-by-step code, with familiar try...catch error handling. [S1]
🧠 핵심 개념 (Core concepts)
- They simplify promises —
asyncandawaitmake promises easier by letting code be written like normal step-by-step code. [S1] asyncreturns a promise — anasyncfunction returns a promise; its return value is what the promise resolves to. [S1]awaitunwraps a promise —awaitpauses inside the async function until the awaited promise resolves, giving back the value directly. [S1]- Error handling with try...catch — wrap awaited calls in
try { ... } catch (error) { ... }to handle rejections. [S1] - Sequential vs parallel — awaiting one call after another runs them in sequence;
Promise.all([...])runs them together and awaits all. [S1]
🧩 추출된 패턴 (Extracted patterns)
- Linearize a promise chain — replace
.then()chaining with successiveawaitcalls inside anasync function. [S1] - try/catch around await — catch a rejected promise (e.g.
await fail()) like a synchronous error. [S1] - Promise.all for parallelism — start promises first, then
await Promise.all([p1, p2])to collect results together. [S1]
📖 세부 내용 (Details)
Promises approach (before) [S1]
// Three functions to run in steps
function step1() {
return Promise.resolve("A");
}
function step2(value) {
return Promise.resolve(value + "B");
}
function step3(value) {
return Promise.resolve(value + "C");
}
// Run the three functions in steps
step1()
.then(function(value) {
return step2(value);
})
.then(function(value) {
return step3(value);
})
.then(function(value) {
myDisplayer(value);
});
async/await approach (after) The same logic reads like sequential code: [S1]
// Function to run the three functions in steps
async function run() {
let v1 = await step1();
let v2 = await step2(v1);
let v3 = await step3(v2);
myDisplayer(v3);
}
run();
The async keyword
An async function returns a promise: [S1]
async function myFunction() {
return "Hello";
}
myFunction().then(
function(value) {myDisplayer(value);}
);
The await keyword
await waits for a promise and returns its resolved value: [S1]
function step1() {
return Promise.resolve("A");
}
async function run() {
let value = await step1();
myDisplayer(value);
}
run();
Error handling with try...catch [S1]
function fail() {
return Promise.reject("Failed");
}
async function run() {
try {
let value = await fail();
console.log(value);
} catch (error) {
console.log(error);
}
}
run();
Sequential execution [S1]
async function run() {
let a = await step1();
let b = await step2();
console.log(a, b);
}
Parallel with Promise.all() Start the promises first, then await them together: [S1]
async function run() {
let p1 = step1();
let p2 = step2();
let values = await Promise.all([p1, p2]);
console.log(values);
}
fetch() with async/await [S1]
async function loadData() {
try {
let response = await fetch("data.json");
let data = await response.json();
console.log(data);
} catch (error) {
console.log(error);
}
}
loadData();
Basic syntax with a Promise Awaiting a constructed promise: [S1]
async function myDisplay() {
let myPromise = new Promise(function(resolve, reject) {
resolve("I love You !!");
});
document.getElementById("demo").innerHTML = await myPromise;
}
myDisplay();
Without the reject parameter: [S1]
async function myDisplay() {
let myPromise = new Promise(function(resolve) {
resolve("I love You !!");
});
document.getElementById("demo").innerHTML = await myPromise;
}
myDisplay();
Waiting for a timeout [S1]
async function myDisplay() {
let myPromise = new Promise(function(resolve) {
setTimeout(function() {resolve("I love You !!");}, 3000);
});
document.getElementById("demo").innerHTML = await myPromise;
}
myDisplay();
🛠️ 적용 사례 (Applied in summary)
The page's snippets — the run() function linearizing step1/step2/step3, the try...catch around await fail(), and await Promise.all([p1, p2]) — are the canonical applied examples. No external project/commit applications found in the source.
💻 코드 패턴 (Code patterns)
Linearize a chain with await (language: JavaScript):
async function run() {
let v1 = await step1();
let v2 = await step2(v1);
let v3 = await step3(v2);
myDisplayer(v3);
}
run();
Error handling and parallelism:
async function run() {
try {
let values = await Promise.all([step1(), step2()]);
console.log(values);
} catch (error) {
console.log(error);
}
}
⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
- Promise
.then()chaining — explicit, but reads as nested handler functions and requires returning each step. [S1] - async/await — the same logic written like normal step-by-step code, with
try...catchfor errors; recommended for readability. Use sequentialawaitfor dependent steps andPromise.allfor independent ones. [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 Promise, JavaScript Async Fetch, JavaScript Async Callbacks, JavaScript Async Debug
- 참조 맥락: The syntactic sugar over promises that most modern async data-fetching code uses.
📚 출처 (Sources)
- [S1] W3Schools — JavaScript Async Await — https://www.w3schools.com/js/js_async_await.asp
📝 변경 이력 (Change history)
- 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript Async Await" page (Astra wiki-curation, P-Reinforce v3.1 format).