in 그리스
poly : many, several, much, multi
morpho- : form(형태), structure(구조), 모양
poly + morphos = many different structures.shapes.forms
before
type SuperPrint = {
(arr: number[]): void
(arr: boolean[]): void
(arr: string[]): void
(arr: number|boolean)[]): void
}
const superPrint: SuperPrint = (arr) => {
arr.forEach(i => console.log(i))
}
superPrint([1, 2, 3, 4])
superPrint([true, false, true])
superPrint(['a', 'b', 'c'])
superPrint([1, 2, true, false])
'Front-end > 타입스크립트로 블록체인 만들기' 카테고리의 다른 글
[TS] Classes (1) | 2024.01.02 |
---|---|
[TS] HW - Polymorphism, Generic Type (1) | 2023.12.21 |
[TS] Why not JavaScript (0) | 2023.12.18 |
[TS] Overloading (0) | 2023.12.15 |
[TS] Call Signatures (0) | 2023.12.15 |