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:
Antigravity Agent
2026-07-05 00:39:13 +09:00
parent 9148c358d0
commit e9cbf23ab5
1356 changed files with 0 additions and 12831 deletions
@@ -0,0 +1,152 @@
---
id: javascript-symbols
title: "JavaScript Symbols"
category: "Frontend"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["JS symbols", "Symbol()", "Symbol.for", "Symbol.iterator", "unique identifier"]
duplicate_of: ""
source_trust_level: "B"
confidence_score: 0.87
created_at: 2026-06-23
updated_at: 2026-06-23
review_reason: ""
merge_history: []
tags: ["javascript", "js", "web", "frontend", "w3schools", "symbol", "data-types", "unique-identifier"]
raw_sources: ["https://www.w3schools.com/js/js_datatypes_symbol.asp"]
applied_in: []
github_commit: ""
---
# [[JavaScript Symbols]]
## 🎯 한 줄 통찰 (One-line insight)
A Symbol is a primitive that represents a unique identifier — every Symbol value is distinct even with identical descriptions — making it ideal for hidden, collision-free object property keys. [S1]
## 🧠 핵심 개념 (Core concepts)
- **Symbol = unique identifier** — a Symbol represents a unique identifier; every Symbol value is distinct, even when created with the same description. [S1]
- **Hidden identifiers** — Symbols act as hidden identifiers that no code can accidentally access, preventing property name conflicts when multiple developers work with shared objects. [S1]
- **Optional description** — `Symbol("id")` attaches a description (label) without affecting uniqueness. [S1]
- **`Symbol.for()` is global/shared** — symbols created with `Symbol.for(key)` are looked up in a global registry, so two `Symbol.for("id")` calls return the same symbol. [S1]
- **`typeof` a symbol is `"symbol"`** — Symbols have their own primitive type. [S1]
## 🧩 추출된 패턴 (Extracted patterns)
- **Symbol as object key** — use `person[id] = 123;` (with `id` a Symbol) to add a property that won't collide with string keys. [S1]
- **Hidden from enumeration/serialization** — Symbol properties are excluded from `for...in` loops and ignored by `JSON.stringify()`. [S1]
- **`Symbol.iterator` makes objects iterable** — define a `[Symbol.iterator]()` method returning a `next()`-based iterator to support `for...of`. [S1]
## 📖 세부 내용 (Details)
**JavaScript Symbols**
A Symbol represents a unique identifier. Symbols are hidden identifiers that no code can accidentally access, which helps prevent accidental property conflicts. Every Symbol value is distinct, even with identical descriptions. [S1]
**Creating Symbols** [S1]
```javascript
const id1 = Symbol();
const id2 = Symbol();
```
**Symbol Descriptions** [S1]
```javascript
const id = Symbol("id");
```
**Uniqueness** — two symbols with the same description are still different: [S1]
```javascript
const id1 = Symbol("id");
const id2 = Symbol("id");
let result = (id1 === id2);
```
**Symbol as Object Property Key** [S1]
```javascript
const id = Symbol("id");
const person = {
firstName: "John",
lastName: "Doe"
};
person[id] = 123;
```
**Type Checking**`typeof` of a symbol is `"symbol"`: [S1]
```javascript
const id = Symbol("id");
let type = typeof id;
```
**Global Symbols**`Symbol.for()` reuses a shared symbol from a global registry: [S1]
```javascript
const id1 = Symbol.for("id");
const id2 = Symbol.for("id");
let result = (id1 === id2);
```
**`Symbol.iterator` Implementation** — define a custom iterator so the object works with `for...of`: [S1]
```javascript
const myObject = {
data: ["A", "B", "C"],
[Symbol.iterator]() {
let index = 0;
let data = this.data;
return {
next() {
if (index < data.length) {
return {value:data[index++], done:false};
} else {
return {done:true};
}
}
};
}
};
let text = "";
for (const x of myObject) {
text += x + "<br>";
}
```
**Notes on behavior**
- **`for...in` loops** — Symbol properties are excluded from `for...in` iteration, maintaining their hidden nature. [S1]
- **JSON serialization** — `JSON.stringify()` ignores Symbol properties entirely. [S1]
- **When to use** — recommended for unique property names, hidden properties, custom iterables, and special behaviors, but cautioned against routine use in everyday code. [S1]
## 🛠️ 적용 사례 (Applied in summary)
The page's own snippets are the canonical applied examples — creating symbols, using one as a `person[id]` key, the `Symbol.for()` global lookup, and the `Symbol.iterator` custom iterable. No external project/commit applications found in the source.
## 💻 코드 패턴 (Code patterns)
Use a Symbol as a collision-free property key (language: JavaScript):
```javascript
const id = Symbol("id");
person[id] = 123;
```
Shared global symbol:
```javascript
const id1 = Symbol.for("id");
const id2 = Symbol.for("id");
let result = (id1 === id2);
```
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
- **`Symbol()` vs `Symbol.for()`** — `Symbol()` always creates a brand-new, unique symbol (even with the same description); `Symbol.for(key)` returns a shared symbol from the global registry, so repeated calls with the same key are equal. Use `Symbol()` for truly private keys and `Symbol.for()` when the same symbol must be retrievable across code. [S1]
- **Symbol key vs string key** — Symbol keys are hidden from `for...in` and `JSON.stringify()`, unlike string keys; choose symbols when a property should not be enumerated or serialized, but prefer ordinary keys for everyday data. [S1]
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
No contradictions found in the source. The page advises against routine use of Symbols in everyday code. [S1]
## ✅ 검증 상태 및 신뢰도
- **상태:** draft
- **검증 단계:** conceptual (실제 적용 사례 발견 시 applied/validated로 승격 가능)
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
- **신뢰 점수:** 0.87
- **중복 검사 결과:** 신규 생성 (New discovery)
## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[JavaScript Tutorial]]
- **관련 개념:** [[JavaScript Data Types]], [[JavaScript Iterables]], [[JavaScript Iterators]], [[JavaScript typeof]]
- **참조 맥락:** Referenced when defining hidden/unique object keys or implementing `Symbol.iterator` for custom iterables.
## 📚 출처 (Sources)
- [S1] W3Schools — JavaScript Symbols — https://www.w3schools.com/js/js_datatypes_symbol.asp
## 📝 변경 이력 (Change history)
- 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript Symbols" page (Astra wiki-curation, P-Reinforce v3.1 format).