Generics Recap
문가가 공부한 기록입니다. 부정확한 내용은 편히 지적 부탁드립니다. //call signature type SuperPrint = (a: T[]) => T const superPrint: SuperPrint = (a) => a[0] const a = superPrint([1, 2, 3, 4]); const b = superPrint([true, false, false]); const c = superPrint(["1", "2", "3"]); const d = superPrint([1, 2, true, false, "무야호"]); console.log(a, b, c, d); // 1 true 1 1 제네릭(Generics)은 기본적으로 placeholder를 사용해 코드의 타입을 우리가 작성한 코드의 타입..
2022. 12. 16.