코드최적화 (1) 썸네일형 리스트형 [TypeScript] 함수 오버로딩의 개념과 주의사항 가이드 type Combinable = string | number;function add1(a: Combinable, b: Combinable) { // return a + b; // 타입 추론이 안되는 경우 타입 어노테이션을 사용해야 함 // 타입가드 : typeof type 의 교차 타입인 경우 if (typeof a === "string" || typeof b === "string") { return a.toString() + b.toString(); } return a + b;}const result = add1("type", "script");result.split(" "); 위 코드에서 const ressult = add1("type", "script"); 로 사용하면 split 에서.. 이전 1 다음