
출처: Type Challenges, https://github.com/type-challenges/type-challenges/blob/main/README.ko.md
3060 - Unshift
`Array.unshift`의 타입 버전을 구현하세요.
type Result = Unshift<[1, 2], 0> // [0, 1, 2,]
풀이
type Unshift<T, U> = T extends [...infer Rest] ? [U, ...Rest] : never
'알고리즘 > Type Challenges' 카테고리의 다른 글
| 898 - Includes (0) | 2023.09.17 |
|---|---|
| 3312 - Parameters (0) | 2023.09.17 |
| 3057 - Push (0) | 2023.09.17 |
| 533 - Concat (0) | 2023.09.06 |
| 268 - If (0) | 2023.09.06 |