| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- theme
- trayicon
- CmdKey
- Capcom
- LogonUI
- 깃티gpg
- Gitea 설치
- gitea
- synology
- jellyfin
- Resident Evil
- DataGridView
- gfd
- Re
- checkbox
- c#
- 깃티
- toroisegit
- 깃티설치
- 시놀로지깃티설치
- Column
- DataTable
- 시놀로지
- Header
- Gitea GPG
- 젤리핀
- 트레이아이콘
- gitea설치
- Resident
- unable to boot the simulator
Archives
- Today
- Total
C O D I N G
데이터 비교시 유의해야할점 본문
""와 ''는 동일하다
"String" === 'String'
"String" == 'String'
비어있는 문자열,
0 문자열,
공백 문자열,
숫자 0
위의 4가지는 false를 의미하기도 함
ex)
'' == '0' // false
0 == '' // true
0 == '0' // true
false == 'false' // false
false == '0' // true
false == undefined // false
false == null // false
null == undefined // true
" \t\r\n" == 0 // true
이와 같은것을 Truthy, Falsy라고 한다.
참조사이트
https://developer.mozilla.org/en-US/docs/Glossary/Truthy
https://developer.mozilla.org/en-US/docs/Glossary/Falsy
truthy와 falsy를 단순히 더블이퀄(==)비교 하게되면 혼돈이 생기기 쉽습니다.
변수 값이 존재하느냐 마느냐는 느낌표를 붙여 판단하면 좋으며,
비교를 위해서는
타입까지 체크하는 트리플이퀄(===)을 사용하는 것이 좋다.
'Programming > JavaScript' 카테고리의 다른 글
| 값 전달 방법 (0) | 2016.05.25 |
|---|