> For the complete documentation index, see [llms.txt](https://yamoo9.gitbook.io/typescript/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yamoo9.gitbook.io/typescript/classes.md).

# 클래스

## 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>" %}
