Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- 파티셔닝
- localStorage
- EventSource
- frontend
- 개발자
- 열공하자
- Partition
- node.js
- SSE
- 실시간알림
- PostgreSQL
- node.js란
- partitioning
- Lag
- 성장기
- Node.js기본
- mariadb
- ServerSentEvent
Archives
- Today
- Total
써치킴의 우당탕탕 개발 블로그
[TypeScript][ch6][Class] Static Properties & Methods 본문
static
클래스의 정적 메소드 정의
클래스의 인스턴스 없이 호출이 가능하며 클래스가 인스턴스화되면 호출할 수 없다.
class Person8 {
static CITY = 'Seoul'; // 공통적으로 사용하고 싶은 데이터가 있다면 static 사용
public static hello(){ // 메소드
console.log('안녕하세요.');
}
}
const p8 = new Person8(); // object 반환
p8.hello(); // Error 발생 : 함수에 static을 붙이면 object는 함수를 메서드라고 생각하지 않는다.
Person8.hello(); // 클래스의 인스턴스 없이 호출이 가능
Person8.CITY;
'TypeScript 합시다' 카테고리의 다른 글
[TypeScript][ch6][Class] 상속(Inheritance) (0) | 2022.02.15 |
---|---|
[TypeScript][ch6][Class] Singletons (0) | 2022.02.15 |
[TypeScript][ch6][Class] index Signatures in class (0) | 2022.02.15 |
[TypeScript][ch6][Class] readonly properties (0) | 2022.02.15 |
[TypeScript][ch6][Class] Getter & Setter (0) | 2022.02.15 |
Comments