πŸ“’[TypeScript λ§ˆμŠ€ν„° with Webpack & React] Step04.λ°°μ—΄ νƒ€μž…

κΆŒμš©μ€€Β·2023λ…„ 12μ›” 6일
0
post-thumbnail

1. λ°°μ—΄ νƒ€μž… 닀루기

TSμ—μ„œλŠ” ν•¨μˆ˜ νŒŒλΌλ―Έν„°, λ°˜ν™˜ κ°’, λ³€μˆ˜λ₯Ό μ–΄λ…Έν…Œμ΄μ…˜ μ²˜λ¦¬ν•¨μœΌλ‘œ 배열이라고 μ•Œ 수 μžˆλ‹€.

const activeUsers: string[] = []; // == const activeUsers: Array<string> = [];

activeUsers.push("Tony")

const ageList: number[] = [45, 56, 130];
ageList[0] = 9;
ageList[0] = "gd"; // error

2. λ°°μ—΄ ꡬ문 더 μ•Œμ•„λ³΄κΈ°


type Point = {
  x: number,
  y: number
}

const coords: Point[] = [];
coords.push({x: 4, y: 12});

3. λ‹€ 차원 λ°°μ—΄


const board: string[][] = [
  ["X","O","X"],
  ["X","O","X"],
  ["X","O","X"],
];
profile
Brendan Eich, Jordan Walke, Evan You, κΆŒμš©μ€€

0개의 λŒ“κΈ€