Files
2nd/10_Wiki/Topics/Domain_Programming/Topic_JavaScript/JavaScript_Symbols.md
T
Antigravity Agent c24165b8bc refactor(topics): 멀티 에이전트용 지식 재편 — _Common(공통 기본기) + Domain_* 구조
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게
[공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류.
문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인).

- Topic_Programming → Domain_Programming (내부 구조 보존)
- Topic_Graphic → Domain_Design
- Topic_Business → Domain_Product
- Topic_General → Domain_General
- _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning),
  Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing)
- 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서)
- 빈 폴더 정리 (memory/procedures)
- 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 11:05:56 +09:00

6.4 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-symbols JavaScript Symbols Frontend draft conceptual
JS symbols
Symbol()
Symbol.for
Symbol.iterator
unique identifier
B 0.87 2026-06-23 2026-06-23
javascript
js
web
frontend
w3schools
symbol
data-types
unique-identifier
https://www.w3schools.com/js/js_datatypes_symbol.asp

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 descriptionSymbol("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]

const id1 = Symbol();
const id2 = Symbol();

Symbol Descriptions [S1]

const id = Symbol("id");

Uniqueness — two symbols with the same description are still different: [S1]

const id1 = Symbol("id");
const id2 = Symbol("id");
let result = (id1 === id2);

Symbol as Object Property Key [S1]

const id = Symbol("id");
const person = {
  firstName: "John",
  lastName: "Doe"
};
person[id] = 123;

Type Checkingtypeof of a symbol is "symbol": [S1]

const id = Symbol("id");
let type = typeof id;

Global SymbolsSymbol.for() reuses a shared symbol from a global registry: [S1]

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]

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 serializationJSON.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):

const id = Symbol("id");
person[id] = 123;

Shared global symbol:

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)

📚 출처 (Sources)

📝 변경 이력 (Change history)

  • 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript Symbols" page (Astra wiki-curation, P-Reinforce v3.1 format).