겨리의 개발일기

고정 헤더 영역

글 제목

메뉴 레이어

겨리의 개발일기

메뉴 리스트

  • 홈
  • 태그
  • 방명록
  • 분류 전체보기 (82)
    • Programming (57)
      • JavaScript (6)
      • TypeScript (4)
      • Vue.js (9)
      • React (12)
      • Spring (1)
      • Algorithm (13)
      • 기타 (12)
    • CS (2)
    • 회고 (14)
    • HTML&CSS (8)

검색 레이어

겨리의 개발일기

검색 영역

컨텐츠 검색

Intersection

  • [TypeScript] 함수와 리터럴, 유니온/교차 타입

    2023.06.20 by 겨리!

[TypeScript] 함수와 리터럴, 유니온/교차 타입

함수 ✅ 타입스크립트로 함수를 작성한 코드 function hello(name: string,age?: number ) : string{ if(age !== undefined) return `Hello, ${name}. You are ${age}.`; else return `Hello, ${name}.`; } console.log(hello('gyeol',30)); // "Hello, gyeol. You are 30." 출력 🤔 만약 매개변수 age를 name보다 먼저 선언하고 싶다면? function hello(age?: number, name: string) : string{ if(age !== undefined) return `Hello, ${name}. You are ${age}.`; else r..

Programming/TypeScript 2023. 6. 20. 21:29

추가 정보

반응형

인기글

최신글

페이징

이전
1
다음
겨리의 개발일기
메일

티스토리툴바