요모조모

  • 홈
  • 태그
  • 방명록

TypeScript 2

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 =..

TypeScript 2025.02.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: 상..

TypeScript 2025.02.11
이전
1
다음
더보기
프로필사진

  • 분류 전체보기 (93)
    • HTML & CSS (9)
    • JavaScript (7)
    • React (0)
    • TypeScript (2)
    • Github (4)
    • Project (0)
    • Error (3)
    • 서적 (12)
      • 모던 자바스크립트 Deep Dive (5)
      • 모두의 네트워크 기초 (7)
    • Tech Interview (0)
    • 회고 (53)
      • Techit Frontend School 10기 (53)
    • 정보처리기사 (1)
    • 기타 (2)

Tag

멋쟁이사자처럼 #프론트엔드스쿨 #멋사, block #inline, 바보, figma, 네트워크, 멋쟁이사자처럼프론트엔드스쿨, reduce(), 멋쟁이사자처럼, lan, wan, 자바스크립트, border # margin # padding, JavaScript,

최근글과 인기글

  • 최근글
  • 인기글

최근댓글

공지사항

페이스북 트위터 플러그인

  • Facebook
  • Twitter

Archives

Calendar

«   2025/11   »
일 월 화 수 목 금 토
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

방문자수Total

  • Today :
  • Yesterday :

Copyright © Kakao Corp. All rights reserved.

티스토리툴바