Files
2nd/10_Wiki/Topics/Domain_Programming/Topic_JavaScript/JavaScript_Classes.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.7 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-classes JavaScript Classes Frontend draft conceptual
ES6 classes
class syntax
constructor method
class methods
use strict
B 0.89 2026-06-23 2026-06-23
javascript
js
web
frontend
w3schools
classes
oop
es6
https://www.w3schools.com/js/js_classes.asp

JavaScript Classes

🎯 한 줄 통찰 (One-line insight)

A JavaScript class, introduced in ES6, is a template for objects (not an object itself), defined with the class keyword and a constructor() method that runs automatically on new. [S1]

🧠 핵심 개념 (Core concepts)

  • Classes are ES6 templates — a class is a template for JavaScript objects, defined with the class keyword and a constructor() method. [S1]
  • A class is not an object — it is a template from which objects are created. [S1]
  • The constructor runs automatically — the constructor method is called automatically when a new object is created with new. [S1]
  • Constructor rules — it must use the exact name constructor, executes automatically, and initializes properties. [S1]
  • Class methods are defined inside the class body and can take parameters. [S1]
  • Strict mode — classes require "strict mode" compliance (e.g. variables must be declared with const/let). [S1]

🧩 추출된 패턴 (Extracted patterns)

  • constructor + this initialization — assign incoming arguments to this.* in the constructor to set up object state. [S1]
  • Method computes from state — methods like age() derive values from the instance's own properties (e.g. this.year). [S1]
  • Pass external data as a parameter — when a method needs outside data (like the current year), pass it in as an argument rather than recomputing. [S1]

📖 세부 내용 (Details)

JavaScript Class Syntax ES6 introduced JavaScript Classes as templates for objects. The basic syntax uses the class keyword with a constructor() method: [S1]

class ClassName {
  constructor() { ... }
}

A concrete example: [S1]

class Car {
  constructor(name, year) {
    this.name = name;
    this.year = year;
  }
}

A JavaScript class is not an object. It is a template for JavaScript objects. [S1]

Using a Class Instantiate with new: [S1]

const myCar1 = new Car("Ford", 2014);
const myCar2 = new Car("Audi", 2019);

The constructor method is called automatically when a new object is created. [S1]

The Constructor Method The constructor must use the exact name constructor, executes automatically when objects are created, and initializes properties. [S1]

Class Methods A method computing the car's age from this.year: [S1]

class Car {
  constructor(name, year) {
    this.name = name;
    this.year = year;
  }
  age() {
    const date = new Date();
    return date.getFullYear() - this.year;
  }
}

const myCar = new Car("Ford", 2014);
document.getElementById("demo").innerHTML =
"My car is " + myCar.age() + " years old.";

A method that accepts a parameter: [S1]

class Car {
  constructor(name, year) {
    this.name = name;
    this.year = year;
  }
  age(x) {
    return x - this.year;
  }
}

const date = new Date();
let year = date.getFullYear();

const myCar = new Car("Ford", 2014);
document.getElementById("demo").innerHTML=
"My car is " + myCar.age(year) + " years old.";

"use strict" Classes require "strict mode" compliance — variables must be properly declared: [S1]

class Car {
  constructor(name, year) {
    this.name = name;
    this.year = year;
  }
  age() {
    // date = new Date();  // This will not work
    const date = new Date(); // This will work
    return date.getFullYear() - this.year;
  }
}

🛠️ 적용 사례 (Applied in summary)

The Car class is the running applied example — defining name/year in the constructor, deriving age in a method (with and without a parameter), and demonstrating strict-mode variable declaration. No external project/commit applications found in the source.

💻 코드 패턴 (Code patterns)

Define a class and instantiate it (language: JavaScript):

class Car {
  constructor(name, year) {
    this.name = name;
    this.year = year;
  }
}
const myCar1 = new Car("Ford", 2014);

Add a method that uses instance state:

age() {
  const date = new Date();
  return date.getFullYear() - this.year;
}

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

No contradictions found in the source.

검증 상태 및 신뢰도

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

🔗 지식 그래프 (Knowledge Graph)

📚 출처 (Sources)

📝 변경 이력 (Change history)

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