# 클래스

## ES6: Class

ES6부터 **클래스 문법을 사용**할 수 있습니다. 클래스를 정의하고, 속성을 설정하는 기본 사용법은 다음과 같습니다.

{% code title="JavaScript" %}

```javascript
/* 클래스 정의 ------------------------------------------------ */
class Book {

  /* 생성자 */
  constructor(title, author, pages) {
    this.title  = title;
    this.author = author;
    this.pages  = pages;
    this.init();
  }

  /* 클래스 메서드 */
  static create(){}

  /* 인스턴스 메서드 */
  init(){}

}

/* 인스턴스 생성 ------------------------------------------------ */

let indRevo = new Book('한 권으로 정리하는 4차 산업혁명', '최진기', 367);
console.log(indRevo); // Book {}
```

{% endcode %}

## TypeScript: Class

TypeScript의 클래스는 ES6의 클래스 문법을 넘어 강력한 기능을 제공합니다.

* access modifiers ( [속성](/typescript/classes/prop-acc-mod.md) | [메서드](/typescript/classes/method-acc-mod.md) )
* [inheritance](/typescript/classes/inherit.md)
* [getter / setter](/typescript/classes/getter-setter.md)
* [static](/typescript/classes/static.md)
* [abstract class](/typescript/classes/abstract-class.md)
* [singleton](/typescript/classes/singleton.md)
* [readonly](/typescript/classes/readonly.md)

{% embed url="<https://stackblitz.com/edit/ts-class?embed=1&file=index.ts&hideExplorer=0&hideNavigation=1&view=editor>" %}

## 참고 <a href="#reference" id="reference"></a>

{% embed url="<https://www.typescriptlang.org/docs/handbook/classes.html>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yamoo9.gitbook.io/typescript/classes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
