Files
2nd/10_Wiki/Topics/Domain_Programming/Topic_JavaScript/JavaScript_Iterables.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

5.8 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-iterables JavaScript Iterables Frontend draft conceptual
JS iterables
iterable protocol
for...of
Symbol.iterator
iterable objects
B 0.88 2026-06-23 2026-06-23
javascript
js
web
frontend
w3schools
iterables
for-of
symbol-iterator
https://www.w3schools.com/js/js_iterables.asp

JavaScript Iterables

🎯 한 줄 통찰 (One-line insight)

Iterables are objects that can be looped over with the for...of statement; in JavaScript, Strings, Arrays, Typed Arrays, Sets, and Maps are all iterable because their prototypes carry a Symbol.iterator method. [S1]

🧠 핵심 개념 (Core concepts)

  • Iterable = loopable with for...of — an iterable is an object that can be iterated (looped) over with the for...of statement. [S1]
  • Built-in iterables — in JavaScript the following are iterables: Strings, Arrays, Typed Arrays, Sets, and Maps, because their prototypes have a Symbol.iterator method. [S1]
  • The iterator protocol — an object becomes an iterator by implementing a next() method that returns an object with value (the next value) and done (a boolean indicating completion). [S1]
  • Symbol.iterator is the hook — an object is made iterable by defining a Symbol.iterator method that returns an iterator. [S1]

🧩 추출된 패턴 (Extracted patterns)

  • for...of over any iterable — the same for (variable of iterable) loop works uniformly across strings, arrays, sets, and maps. [S1]
  • Custom iterable via Symbol.iterator — attach a Symbol.iterator function to a plain object so it can be used in for...of, giving you custom iteration logic for your own data structures. [S1]

📖 세부 내용 (Details)

Iterables Iterables are iterable objects (like Arrays). Iterables can be accessed with simple and efficient code. Iterables can be iterated over with for...of loops. [S1]

The for...of Loop The for...of statement loops through the elements of an iterable object. Its syntax is: [S1]

for (variable of iterable) {
  // code block to be executed
}

Iterating over a String You can use a for...of loop to iterate over the elements of a string: [S1]

const name = "W3Schools";

for (const x of name) {
  // code block to be executed
}

Iterating over an Array You can use a for...of loop to iterate over the elements of an array: [S1]

const letters = ["a","b","c"];

for (const x of letters) {
  // code block to be executed
}

Iterating over Sets and Maps for...of can also iterate over the elements of a Set and over the key/value pairs of a Map. [S1]

JavaScript Iterators The for...of loop relies on an iterator. The iterable must implement a method named Symbol.iterator. The Symbol.iterator method is called automatically by for...of. It returns an iterator object with a next() method. The next() method returns an object with a value property (the next value) and a done property (true or false). [S1]

Built-in Iterables In JavaScript the following are iterables: Strings, Arrays, Typed Arrays, Sets, and Maps. They are iterable because their prototype objects all have a Symbol.iterator method. [S1]

A User-Defined (Home-Made) Iterable You can make an object iterable by giving it a Symbol.iterator method. The example below creates an object that returns values 10, 20, 30, 40 ... and stops at 100: [S1]

myNumbers = {};

myNumbers[Symbol.iterator] = function() {
  let n = 0;
  done = false;
  return {
    next() {
      n += 10;
      if (n == 100) {done = true}
      return {value:n, done:done};
    }
  };
}

for (const num of myNumbers) {
  // Any Code Here
}

The next() method returns an object with two properties: value (the next value) and done (true when iteration is finished). [S1]

🛠️ 적용 사례 (Applied in summary)

The page's own snippets are the canonical applied examples — looping over the string "W3Schools", the array ["a","b","c"], and the home-made myNumbers iterable built with Symbol.iterator. No external project/commit applications found in the source.

💻 코드 패턴 (Code patterns)

Loop over any iterable (language: JavaScript):

for (const x of "W3Schools") {
  // code block to be executed
}

Make a plain object iterable:

myNumbers[Symbol.iterator] = function() {
  let n = 0;
  done = false;
  return {
    next() {
      n += 10;
      if (n == 100) {done = true}
      return {value:n, done:done};
    }
  };
}

⚖️ 모순 및 업데이트 (Contradictions & updates)

No contradictions found in the source.

검증 상태 및 신뢰도

  • 상태: draft
  • 검증 단계: conceptual (실제 적용 사례 발견 시 applied/validated로 승격 가능)
  • 출처 신뢰도: B (W3Schools — widely used educational reference, not a primary standards body)
  • 신뢰 점수: 0.88
  • 중복 검사 결과: 신규 생성 (New discovery)

🔗 지식 그래프 (Knowledge Graph)

📚 출처 (Sources)

📝 변경 이력 (Change history)

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