클래스 / 상속 / 접근제한자 / 접근자 클래스 Class typescript 클래스는 클래스 몸체에 클래스 프로퍼티를 사전 선언하여야 한다. class Animal { // 클래스 프로퍼티를 사전 선언하여야 한다 name: string; constructor(name: string) { // 클래스 프로퍼티에 값을 할당 this.name = name; } status() { console.log(`${this.name} is cute.`); } } const animal = new Animal('Dog'); animal.status(); // Dog is cute. 클래스 Animal 은 세 개의 멤버를 가지고 있다. name 프로퍼티, 생성자constructor, status 메소드이다. 클래스 안에서 클래스의 멤버를 참조할 때 this 를.. 2021. 7. 27. 이전 1 다음