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>
This commit is contained in:
@@ -0,0 +1,177 @@
|
||||
---
|
||||
id: javascript-errors-intro
|
||||
title: "JavaScript Errors Intro"
|
||||
category: "Frontend"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["JavaScript errors", "try catch throw", "ReferenceError", "TypeError", "RangeError", "error handling"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-06-23
|
||||
updated_at: 2026-06-23
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["javascript", "js", "web", "frontend", "w3schools", "errors", "try-catch"]
|
||||
raw_sources: ["https://www.w3schools.com/js/js_errors_intro.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[JavaScript Errors Intro]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Errors will happen in running JavaScript code; `try` tests a block for runtime errors and `catch` handles them via an error object whose `name` identifies the error type. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Errors will happen** — many error types can occur during execution: Reference Errors, Type Errors, Range Errors, URI Errors, Syntax Errors, and Eval Errors. [S1]
|
||||
- **try / catch** — the `try` statement tests a block of code for errors during execution; the `catch` statement handles the error if one occurs. [S1]
|
||||
- **The error object** — the `catch` block receives an error object; `err.name` returns the type of error. [S1]
|
||||
- **Syntax errors are special** — a `SyntaxError` happens before runtime, so it is not catchable by ordinary `try...catch`. [S1]
|
||||
- **EvalError is legacy** — newer JavaScript versions raise `SyntaxError` instead of `EvalError`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Wrap risky code, inspect `err.name`** — put the operation that may fail inside `try`, then read `err.name` in `catch` to discover which error type occurred. [S1]
|
||||
- **Trigger by error category** — each error type is provoked by a distinct kind of mistake: undefined references → `ReferenceError`; wrong-type operations → `TypeError`; out-of-range values → `RangeError`; illegal URI characters → `URIError`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
**Errors Will Happen!**
|
||||
While executing JavaScript code, different errors can occur, including Reference Errors, Type Errors, Range Errors, URI Errors, Syntax Errors, and Eval Errors. [S1]
|
||||
|
||||
**How to Handle JavaScript Errors**
|
||||
The `try` statement tests a block of code for errors during execution, while `catch` handles errors if they occur. [S1]
|
||||
|
||||
**Reference Errors**
|
||||
A `ReferenceError` occurs when referencing a variable that doesn't exist or accessing a variable before initialization. [S1]
|
||||
|
||||
Using a non-existing variable: [S1]
|
||||
```javascript
|
||||
let x = 5;
|
||||
|
||||
try {
|
||||
x = y + 1;
|
||||
} catch(err) {
|
||||
let text = err.name;
|
||||
}
|
||||
```
|
||||
|
||||
Accessing a variable before initialization: [S1]
|
||||
```javascript
|
||||
try {
|
||||
let x = y;
|
||||
let y = 5;
|
||||
} catch(err) {
|
||||
let text = err.name;
|
||||
}
|
||||
```
|
||||
|
||||
**JavaScript Type Errors**
|
||||
A `TypeError` occurs when a value is the wrong type or an operation is invalid on that type. [S1]
|
||||
|
||||
Calling a non-function: [S1]
|
||||
```javascript
|
||||
let anna = 5;
|
||||
try {
|
||||
anna(5);
|
||||
} catch(err) {
|
||||
let text = err.name;
|
||||
}
|
||||
```
|
||||
|
||||
Invalid method on a number: [S1]
|
||||
```javascript
|
||||
let num = 1;
|
||||
try {
|
||||
num.toUpperCase();
|
||||
} catch(err) {
|
||||
let text = err.name;
|
||||
}
|
||||
```
|
||||
|
||||
**JavaScript Range Errors**
|
||||
A `RangeError` occurs when a value falls outside its valid range. [S1]
|
||||
|
||||
Invalid array length: [S1]
|
||||
```javascript
|
||||
try {
|
||||
new Array(-1);
|
||||
} catch(err) {
|
||||
let text = err.name;
|
||||
}
|
||||
```
|
||||
|
||||
Invalid precision argument: [S1]
|
||||
```javascript
|
||||
let num = 1;
|
||||
|
||||
try {
|
||||
num.toPrecision(500);
|
||||
} catch(err) {
|
||||
let text = err.name;
|
||||
}
|
||||
```
|
||||
|
||||
**JavaScript URI Errors**
|
||||
A `URIError` occurs with illegal characters in URI functions. [S1]
|
||||
```javascript
|
||||
try {
|
||||
decodeURI("%%%");
|
||||
} catch(err) {
|
||||
document.getElementById("demo").innerHTML = err.name;
|
||||
}
|
||||
```
|
||||
|
||||
**JavaScript Syntax Errors**
|
||||
A `SyntaxError` occurs when code violates JavaScript grammar rules. Syntax errors are not catchable by `try...catch` because they happen before runtime. [S1]
|
||||
```javascript
|
||||
try {
|
||||
let x = Math.round(4.6;)
|
||||
} catch(err) {
|
||||
let text = err.name + " " + err.description;
|
||||
}
|
||||
```
|
||||
|
||||
**JavaScript Eval Error**
|
||||
An `EvalError` indicates an error in the `eval()` function. Newer JavaScript versions use `SyntaxError` instead. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
The page's own snippets are the canonical applied examples — each wraps a deliberate mistake in `try` and reads `err.name` in `catch` to surface the resulting error type. No external project/commit applications found in the source.
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Wrap risky code and inspect the error type (language: JavaScript):
|
||||
```javascript
|
||||
try {
|
||||
// code that may throw
|
||||
} catch(err) {
|
||||
let text = err.name;
|
||||
}
|
||||
```
|
||||
Provoke each error category:
|
||||
```javascript
|
||||
x = y + 1; // ReferenceError (y not defined)
|
||||
anna(5); // TypeError (anna is not a function)
|
||||
new Array(-1); // RangeError (invalid array length)
|
||||
decodeURI("%%%"); // URIError (illegal URI characters)
|
||||
```
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **EvalError deprecation** — the source notes that newer JavaScript versions raise `SyntaxError` instead of `EvalError`, so `EvalError` is effectively legacy. [S1]
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual (실제 적용 사례 발견 시 applied/validated로 승격 가능)
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[JavaScript Tutorial]]
|
||||
- **관련 개념:** [[JavaScript Silent Errors]], [[JavaScript Error Statements]], [[JavaScript Error Object]], [[JavaScript Debugging]]
|
||||
- **참조 맥락:** The starting point for understanding which JavaScript error types exist and how `try...catch` surfaces them.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — JavaScript Errors Intro — https://www.w3schools.com/js/js_errors_intro.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript Errors Intro" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
Reference in New Issue
Block a user