Optional chaining๐Ÿ”—

๋‚˜๋Š”์•ผ ํ† ๋งˆํ† ยท2022๋…„ 3์›” 6์ผ
0

JavaScript๐Ÿ’›

๋ชฉ๋ก ๋ณด๊ธฐ
2/15
post-thumbnail

Optional chaining์ด๋ž€?

?. ์—ฐ์‚ฐ์ž

ํ•จ์ˆ˜ ํ˜ธ์ถœ์—์„œ ์‚ฌ์šฉ๋  ๋•Œ, ๋งŒ์•ฝ ์ฃผ์–ด์ง„ ํ•จ์ˆ˜๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š๋Š”๋‹ค๋ฉด, undefined๋ฅผ ๋ฆฌํ„ดํ•จ => ์—๋Ÿฌ ๋ฐœ์ƒํ•˜๋Š” ๊ฒƒ ๋Œ€์‹ ์—!!!
&& ์—ฐ์‚ฐ์ž๋ฅผ ๋Œ€์‹ ํ•˜์—ฌ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์–ด์„œ ์ฝ”๋“œ๊ฐ€ ๋” ๊ฐ„ํŽธํ•ด์ง!!!!!

&& ์—ฐ์‚ฐ์ž ์ด์šฉ ์‹œ

{animalList && animalList.dog && (
	<div>
		{animalList.dog}
	</div>
)}

Optional Chaining ์ด์šฉ์‹œ

{animalList.dog ?. (
	<div>
		{animalList.dog}
	</div>
)}
profile
ํ† ๋งˆํ† ๋งˆํ† 

0๊ฐœ์˜ ๋Œ“๊ธ€