typescript는 type-based 언어이며, javascript와 함께 사용하여 강력한 능력을 제공함

 

1. string
const test: string = `Hello ${test}!`;

 

2. number

javascript와 같이 모두 floating-point value로 처리

const name: number = 25;

 

3. boolean

const isBool: boolean = true;

 

4. arrays

const numArray: number[] = [1, 3, 5, 7, 11];

 

5. tuple

특정한 구조를 가지고 있는, 2가지 요소를 가진 배열과 비슷

let name: [number, string]

name = [1, 'test1'[;

console.log(`test...${name[0]} ,,,  ${name[1]}`);

 

6. enum

javascript에 object와 비슷

 

enum Color {

    Red = '#FF0000',

    Blue = '#0000FF',

    Green = '#00FF00',

}

 

console.log(Color.Red);

 

7. objects

objects는 속성을 가지고 있는 특별한 형태의 form

 

interface iUser {

    id: number,

    name: string,

    age: number;

}

 

const user: iUser = {

    id: 1,

    name: 'test1',

    age: 30

};

 

'기타' 카테고리의 다른 글

How to find the reason MySQL Heatwave is not offload  (0) 2023.04.18
Spring Cloud Netfix  (0) 2020.03.12
prometheus 모니터링  (0) 2020.02.02
ansible library 확장  (0) 2019.09.13
ansible 소스 설치  (0) 2019.09.12

+ Recent posts