![20240709095826_uwBGlqFLHR.jpeg](//cdn2.ppomppu1.co.kr/zboard/data3/2024/0709/20240709095826_uwBGlqFLHR.jpeg) ![20240709095829_hxUtui6l0s.jpeg](//cdn2.ppomppu1.co.kr/zboard/data3/2024/0709/20240709095829_hxUtui6l0s.jpeg) ![20240709095830_Emnxgae3m9.jpeg](//cdn2.ppomppu1.co.kr/zboard/data3/2024/0709/20240709095830_Emnxgae3m9.jpeg) ![20240709095832_zcLnxpLzho.jpeg](//cdn2.ppomppu1.co.kr/zboard/data3/2024/0709/20240709095832_zcLnxpLzho.jpeg) ![20240709095835_hxewnVY8tv.jpeg](//cdn2.ppomppu1.co.kr/zboard/data3/2024/0709/20240709095835_hxewnVY8tv.jpeg) ![20240709095838_XUs9oxHH8R.jpeg](//cdn2.ppomppu1.co.kr/zboard/data3/2024/0709/20240709095838_XUs9oxHH8R.jpeg) ![20240709095841_edbgBVwyGR.jpeg](//cdn2.ppomppu1.co.kr/zboard/data3/2024/0709/20240709095841_edbgBVwyGR.jpeg) ![20240709095842_0Hq6uTssfj.jpeg](//cdn2.ppomppu1.co.kr/zboard/data3/2024/0709/20240709095842_0Hq6uTssfj.jpeg) ![20240709095844_cYsc8AEPwA.jpeg](//cdn2.ppomppu1.co.kr/zboard/data3/2024/0709/20240709095844_cYsc8AEPwA.jpeg) : (1) Falsy values are values that are not exactly false, but becomes false when converted into a boolean.
(2) ±×¸² 1: In Javascript, there are only five falsy values. 1️⃣ 0 2️⃣ ¡¯¡¯ 3️⃣ undefined 4️⃣ null 5️⃣ NaN 👉 All of these 5 values will converted to false when we attempt to convert them to a boolean. They¡¯re not exactly false initially, but they will become false when converted to a boolean.
(3) Apart from those 5 falsy values mentioned in (2), everything else are truthy values. For example, any number that is not zero or any string that is not an empty string (¡®¡¯) will be converted to true when we attempt to convert them to a boolean.
(4) Although values can be converted to boolean type manually or explicitly, in practice, the conversion to boolean is always implicit, not explicit.
(5) Javascript does type coercion to booleans (automatically) in 2 scenarios: 1️⃣ When using logical operators. (ÀÌÈÄ °ÀÇ¿¡¼ ´Ù·ïÁú °Í) 2️⃣ ±×¸² 2~4: In a logical context. For example: in the condition of an if else statement
(6) Triple equal (===) is a comparison operator. It is called strict equality operator. It is strict because it does not perform type coercion. And so, it only returns true when both values are exactly the same.
(7) Double equal (==) is also a comparison operator called loose equality operator. And unlike triple equal, it actually performs type coercion.
(8) ±×¸² 5~7À» ÅëÇØ strict equality operator¿Í loose equality operatorÀÇ Â÷À̸¦ ÀÌÇØÇÒ °Í
(9) As a general rule for clean code, avoid the loose equality operator as much as you can. When comparing values, always use strict equality operator.
(10) ±×¸² 8~9: prompt() ÇÔ¼ö¿¡ ÀÎÀÚ¸¦ ÀÔ·ÂÇßÀ» ½Ã, ¹®ÀÚ¿À» ¹ÝȯÇÑ´Ù.
(11) The opposite of strict equality operator (===) and loose equality operator (==) are: !==, != |
¾È¿Ã¸®¼Åµµ µË´Ï´Ù
@anonymousStruct
Á¦°¡ 10³âÂ÷Àε¥..
»Ë»Ñ °³¹ßÀÚ Æ÷·³Àº Á¦°¡ °ÅÁø ¸·³»¿©¼.. ´Ùµé ½ÃÅ«µÕ ÇϽǰſ¡¿ä -