ES6: Class
ES6부터 클래스 문법을 사용할 수 있습니다. 클래스를 정의하고, 속성을 설정하는 기본 사용법은 다음과 같습니다.
/* 클래스 정의 ------------------------------------------------ */
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 {}
TypeScript: Class
TypeScrit의 클래스는 ES6의 클래스 문법을 넘어 강력한 기능을 제공합니다.