Unionμ νλμ λ³μμ μ¬λ¬ νμ
μ μ ν λ μ¬μ©νλ€.
function combine(input1: number | string, input2: number | string) { let result; if (typeof input1 === 'number' && typeof input2 === 'number') { result = input1 + input2; } else { result = input1.toString() + input2.toString(); } return result; } const combinedAges = combine(30, 26); console.log(combinedAges); const combinedNames = combine('Max', 'Anna'); console.log(combinedNames);
νλμ κ°μ ν¨μλ‘ ifλ¬Έμ μ΄μ©ν΄μ κ°κ° λ€λ₯Έ νμ
μ μΆλ ₯ ν μμλ€.
λ pipe λΌκ³ λΆλ₯Έλ€.
Β