TypeScript #1 기본 타입

henry·2021년 4월 10일
1
post-thumbnail

타입스크립트로 변수나 함수와 같은 자바스크립트 코드에 타입을 정의할 수 있다.

타입스크립트의 12가지의 기본 타입

  • Boolean
  • Number
  • String
  • Object
  • Array
  • Tuple
  • Enum
  • Any
  • Void
  • Null
  • Undefined
  • Never

1. String

const str: string = 'hello';

// 타입이 문자열인 경우 

2. number

const num:number = -6;

3. boolean

const boal: boolean = false

4. undefined

// 비었는지 안 비었는지 결정이 안 된 상태

5. null

// 비어있다고 결정이 됨

6. unknown

7. any

8. void

9. never


10. Object

11. Tuple

열의 길이가 고정되고 각 요소의 타입이 지정되어 있는 배열 형식

12. Enum

profile
나 김헨리

0개의 댓글