티스토리

요모조모
검색하기

블로그 홈

요모조모

kellyjs.tistory.com/m

kelly09 님의 블로그입니다.

구독자
1
방명록 방문하기

주요 글 목록

  • type과 interface 둘이 어떤 차이가 있는지? 확장 방법의 차이interface는 extends를 사용하여 확장 가능함.type은 &(intersection) 연산자를 사용하여 결합 가능함.interface Dessert { name: string;}interface Cake extends Dessert { fruit(): void;}type DessertType = { name: string;}type CakeType = DessertType & { fruit(): void;}; 합집합(Union) 타입 지원 여부type은 유니언을 이용한 타입 조합이 가능, interface는 불가능interface A { name: string;}interface B { age: number;}// type에서는 가능type C =.. 공감수 0 댓글수 0 2025. 2. 13.
  • implements와 extends TypeScript에서 class를 공부하던 중 헷갈려서 정리하게 되었다. 둘 다 class 상속의 유형들이다. implements: 인터페이스 구현인터페이스에 정의된 구조를 강제할 때 사용함.인터페이스는 실제 구현이 없고, 클래스가 인터페이스를 구현해야 함.interface Flyable { fly(): void;}class Bird implements Flyable } fly() { console.log("파닥파닥"); }}const myBird = new Bird();myBird.fly(); // "파닥파닥"인터페이스를 구현하는 클래스는 반드시 인터페이스의 모든 속성과 메서드를 정의해야 함.implements 절을 사용하면 클래스가 특정 인터페이스를 충족하는지 확인할 수 있음. extends: 상.. 공감수 0 댓글수 0 2025. 2. 11.
    문의안내
    • 티스토리
    • 로그인
    • 고객센터

    티스토리는 카카오에서 사랑을 담아 만듭니다.

    © Kakao Corp.