문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판이전 판다음 판 | 이전 판 | ||
| typescript:class [2019/07/27 05:38] – [Readonly Property] taekgu | typescript:class [2025/04/15 10:05] (현재) – 바깥 편집 127.0.0.1 | ||
|---|---|---|---|
| 줄 184: | 줄 184: | ||
| } | } | ||
| } | } | ||
| - | |||
| let book:Book = new Book(' | let book:Book = new Book(' | ||
| + | book.btitle = ' | ||
| - | book.btitle = ' | ||
| 다음의 예제처럼 생성자의 parameter를 readonly로 선언하면 따로 class의 property로 선언할 필요가 없습니다. | 다음의 예제처럼 생성자의 parameter를 readonly로 선언하면 따로 class의 property로 선언할 필요가 없습니다. | ||
| <code javascript> | <code javascript> | ||
| 줄 195: | 줄 194: | ||
| } | } | ||
| } | } | ||
| - | |||
| let book:Book = new Book(' | let book:Book = new Book(' | ||
| - | + | console.log(book.btitle); | |
| - | console.log(book.btitle); | + | </ |
| ==== Static Property ==== | ==== Static Property ==== | ||
| static 키워드 역시 사용할 수 있습니다. ECMAScript 2015에서는 static을 method에만 적용할 수 있었지만 TypeScript는 property에도 적용할 수 있습니다. static property는 class의 이름으로 직접 access를 할 수 있습니다. | static 키워드 역시 사용할 수 있습니다. ECMAScript 2015에서는 static을 method에만 적용할 수 있었지만 TypeScript는 property에도 적용할 수 있습니다. static property는 class의 이름으로 직접 access를 할 수 있습니다. | ||