[TIL] 221127

BeanxxΒ·2022λ…„ 11μ›” 27일
0

TIL

λͺ©λ‘ 보기
104/120
post-thumbnail

πŸ”₯ 였늘 ν•œ 일


🧚 μƒˆλ‘­κ²Œ μ•Œκ²Œ 된 λ‚΄μš©


const add = (a: number, b: number = 1) => a + b;
const printOutput: (a: nubmer | string) => void = output => console.log(output);
printOutput(add(5));

// (a: number = 1, b: number)일 경우 λ§€κ°œλ³€μˆ˜λ‘œ ν•˜λ‚˜λ§Œ λ°›μœΌλ©΄ error!
// why? ν•˜λ‚˜μ˜ λ§€κ°œλ³€μˆ˜κ°€ μ•žμ—μ„œλΆ€ν„° ν• λ‹Ήλ˜λ―€λ‘œ 5κ°€ aμ—κ²Œ 전달됨
// => 기본값을 μ„ μ–Έν•  땐 였λ₯Έμͺ½ μΈμžμ—!!
const hobbies ['Sports', 'Cooking'];
const activeHobbies = ['Hiking'];

activeHobbies.push(...hobbies);

// activeHobbies: ['Hiking', 'Sports', 'Cooking']
// λ§€κ°œλ³€μˆ˜ κ°œμˆ˜κ°€ μ •ν•΄μ Έ μžˆμ§€ μ•Šμ„ λ•Œ
const add = (...numbers: number[]) => {
	return numbers.reduce((acc, cur) => {
		return acc + cur;
	}, 0);
}

// λ§€κ°œλ³€μˆ˜ 개수λ₯Ό μ•Œκ³  μžˆμ„ λ•Œ νŠœν”Œ μ‚¬μš©!
(...numbers: [number, number, number])

✍️ Diary

λ©΄μ ‘ 쀀비도 κΎΈμ€€νžˆ ν•΄μ•Ό ν•˜λŠ”λ° 계속 미루게 λœλ‹€..
λ‚ΌλΆ€ν„΄ λ©΄μ ‘ 쀀비에도 μ΅œμ†Œ 2μ‹œκ°„ 이상 μ‹œκ°„ ν• μ• ν•˜κΈ°!
λ―Έλ€„λ†¨λ˜ react-hook-formκ³Ό portal modal κ΅¬ν˜„ κ³Όμ • ν¬μŠ€νŠΈλ„ 였늘 λ‹€ μ—…λ‘œλ“œν–ˆλ‹€. ν›„λ ¨ν›„λ ¨ 😽
막 μ¨λ†¨λ˜ Velog 글듀도 ν‹ˆν‹ˆνžˆ μ‘°κΈˆμ”© λ‹€λ“¬μ–΄λ³΄μŸˆ πŸ™Œ

profile
FE developer

0개의 λŒ“κΈ€