docs(10_Wiki): Dev 폴더 누락분 반영 — Topic_Programming으로 통합
이전 재구성 작업에서 Dev/ 폴더가 누락되었던 것을 반영. - Dev/Topic_Programming(중첩 폴더, 78개)은 Dev 자체 최상위 폴더들 (Architecture/Conventions/Engineering_Intelligence 등)과 완전 중복이라 제거. - Dev 최상위 엔지니어링 지식 폴더(Architecture/Conventions/Engineering_Intelligence/ Failure_Library/Generalized_Principles/Language/Pattern_Catalog/Platform_Guides/ Subsystems, 77개)는 이미 Topic_Programming/Topic_Programming에 더 최신 버전이 존재해 중복 제거(고유 콘텐츠 1개는 예외 처리하여 이동 보존). - Dev의 W3Schools 언어 튜토리얼 폴더(Topic_C/CPP/CSS/CSharp/HOWTO/HTML/Java/ JavaScript/PHP/Python/SQL/W3CSS, 1201개)는 전부 Topic_Programming 하위로 이동. - 에이전트 운영 상태(.astra/docs)는 그대로 유지, 콘텐츠 폴더만 정리. - Topic_Programming 최종 문서 수: 2784 → 3985.
This commit is contained in:
@@ -0,0 +1,184 @@
|
||||
---
|
||||
id: javascript-strict-mode
|
||||
title: "JavaScript Strict Mode"
|
||||
category: "Frontend"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["use strict", "strict mode", "ECMAScript 5 strict", "strict directive", "JS strict"]
|
||||
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", "strict-mode", "use-strict", "es5"]
|
||||
raw_sources: ["https://www.w3schools.com/js/js_strict.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[JavaScript Strict Mode]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`"use strict";` (ECMAScript 5) makes JavaScript run in strict mode, turning previously-tolerated "bad syntax" into real errors. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`"use strict"` is a directive** — it is a literal expression, ignored by older JavaScript versions, that tells the engine to execute code in strict mode. [S1]
|
||||
- **Introduced in ES5** — strict mode was added in ECMAScript 5. [S1]
|
||||
- **Two scopes** — declared at the top of a script it applies globally; declared at the top of a function it applies only inside that function. [S1]
|
||||
- **Must appear at the beginning** — the directive must be at the start of the script or function to be recognized. [S1]
|
||||
- **Turns mistakes into errors** — strict mode makes it easier to write secure code by converting silent bad syntax into thrown errors (e.g. prevents accidental globals). [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Opt into safety per file or per function** — place `"use strict";` at the top of a script (global) or a function (local). [S1]
|
||||
- **Declare before use** — strict mode forbids using undeclared variables/objects, forcing explicit declarations. [S1]
|
||||
- **Avoid deprecated/unsafe constructs** — `with`, octal literals, duplicate parameters, deleting variables, etc. are all disallowed. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
**Declaring strict mode**
|
||||
Strict mode is declared by adding `"use strict";` to the beginning of a script or a function. Declared at the beginning of a script, it has global scope (all code in the script executes in strict mode): [S1]
|
||||
```javascript
|
||||
"use strict";
|
||||
x = 3.14; // This will cause an error because x is not declared
|
||||
```
|
||||
Declared inside a function, it has local scope (only the code inside the function is in strict mode): [S1]
|
||||
```javascript
|
||||
"use strict";
|
||||
myFunction();
|
||||
|
||||
function myFunction() {
|
||||
y = 3.14; // This will cause an error
|
||||
}
|
||||
```
|
||||
|
||||
**Why strict mode?**
|
||||
Strict mode makes it easier to write "secure" JavaScript. It changes previously accepted "bad syntax" into real errors. For example, in normal JavaScript, mistyping a variable name creates a new global variable; in strict mode this throws an error, so you cannot accidentally create a global variable. [S1]
|
||||
|
||||
**Not allowed in strict mode**
|
||||
|
||||
Using a variable (or object) without declaring it: [S1]
|
||||
```javascript
|
||||
"use strict";
|
||||
x = 3.14; // This will cause an error
|
||||
```
|
||||
```javascript
|
||||
"use strict";
|
||||
x = {p1:10, p2:20}; // This will cause an error
|
||||
```
|
||||
|
||||
Deleting a variable (or object) or a function is not allowed: [S1]
|
||||
```javascript
|
||||
"use strict";
|
||||
let x = 3.14;
|
||||
delete x; // This will cause an error
|
||||
```
|
||||
```javascript
|
||||
"use strict";
|
||||
function x(p1, p2) {};
|
||||
delete x; // This will cause an error
|
||||
```
|
||||
|
||||
Duplicating a parameter name is not allowed: [S1]
|
||||
```javascript
|
||||
"use strict";
|
||||
function x(p1, p1) {}; // This will cause an error
|
||||
```
|
||||
|
||||
Octal numeric literals and octal escape characters are not allowed: [S1]
|
||||
```javascript
|
||||
"use strict";
|
||||
let x = 010; // This will cause an error
|
||||
```
|
||||
```javascript
|
||||
"use strict";
|
||||
let x = "\010"; // This will cause an error
|
||||
```
|
||||
|
||||
Writing to a read-only property is not allowed: [S1]
|
||||
```javascript
|
||||
"use strict";
|
||||
const obj = {};
|
||||
Object.defineProperty(obj, "x", {value:0, writable:false});
|
||||
obj.x = 3.14; // This will cause an error
|
||||
```
|
||||
|
||||
Writing to a get-only property is not allowed: [S1]
|
||||
```javascript
|
||||
"use strict";
|
||||
const obj = {get x() {return 0} };
|
||||
obj.x = 3.14; // This will cause an error
|
||||
```
|
||||
|
||||
Deleting an undeletable property is not allowed: [S1]
|
||||
```javascript
|
||||
"use strict";
|
||||
delete Object.prototype; // This will cause an error
|
||||
```
|
||||
|
||||
The word `eval` cannot be used as a variable: [S1]
|
||||
```javascript
|
||||
"use strict";
|
||||
let eval = 3.14; // This will cause an error
|
||||
```
|
||||
|
||||
The word `arguments` cannot be used as a variable: [S1]
|
||||
```javascript
|
||||
"use strict";
|
||||
let arguments = 3.14; // This will cause an error
|
||||
```
|
||||
|
||||
The `with` statement is not allowed: [S1]
|
||||
```javascript
|
||||
"use strict";
|
||||
with (Math){x = cos(2)}; // This will cause an error
|
||||
```
|
||||
|
||||
For security reasons, `eval()` is not allowed to create variables in the scope from which it was called: [S1]
|
||||
```javascript
|
||||
"use strict";
|
||||
eval ("var x = 2");
|
||||
alert (x); // This will cause an error
|
||||
```
|
||||
|
||||
**The "use strict" directive**
|
||||
The `"use strict"` directive is only recognized at the beginning of a script or a function. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
The page's snippets are the applied cases: each shows a construct that runs silently (or wrongly) in normal mode but throws under `"use strict";` — undeclared assignment, `delete` on variables/functions, duplicate parameters, octal literals, read-only/get-only writes, reserved words `eval`/`arguments`, `with`, and `eval()` scope injection. No external project/commit applications found in the source.
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Enable strict mode globally (top of script) (language: JavaScript):
|
||||
```javascript
|
||||
"use strict";
|
||||
x = 3.14; // Error: x is not declared
|
||||
```
|
||||
Enable strict mode for a single function:
|
||||
```javascript
|
||||
function myFunction() {
|
||||
"use strict";
|
||||
// strict-mode code here
|
||||
}
|
||||
```
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
No contradictions found in the source. The page notes that older browsers/JavaScript versions simply ignore the `"use strict";` string, so it is backward-compatible.
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual (실제 적용 사례 발견 시 applied/validated로 승격 가능)
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[JavaScript Tutorial]]
|
||||
- **관련 개념:** [[JavaScript Scope]], [[JavaScript Hoisting]], [[JavaScript var let const]], [[JavaScript Best Practices]]
|
||||
- **참조 맥락:** Referenced when hardening JavaScript against silent errors and accidental globals.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — JavaScript Strict Mode — https://www.w3schools.com/js/js_strict.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript Strict Mode" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
Reference in New Issue
Block a user