Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 반복문
- javascript
- ReactNative
- input함수
- inflearn
- while
- vs code
- 점프투장고
- Swift
- sd()
- f-string
- COUNT()
- python
- notion
- R 데이터 분석
- react
- pycharm
- 제어문
- 멤버십 연산자
- Django
- mutate()
- group_by()
- 동일성 연산자
- 별찍기
- 소수출력
- match case
- sqldf
- summarise()
- 자료형
- 조건문
Archives
- Today
- Total
✏️
논리 연산자(AND, OR, NOT) 본문
OR || : 여러개 중 하나라도 true면 true / 모든 값이 false일때만 false를 반환
AND && : 모든 값이 true이면 true / 하나라도 false면 false
NOT ! : true면 false / fasle면 true
ex) 스티브잡스는 한국인이거나(or) 남자이다 => true
스티브잡스는 한국인이고(and) 남자이다 => false
// 이름이 Tom이거나, 성인이면 통과
const name = 'Mike';
const age = 30;
if(name === 'Tom' || age > 19){
console.log('통과입니다.');
}
// 이름은 Tom이 아니지만 성인이라 통과
비교연산자 우선순위
AND > OR
// 남자이고, 이름이 Mike이거나 성인이면 통과
const gender = 'F';
const name = 'Jane';
const isAdult = true;
if(gender === 'M' && name === 'Mike' || isAdult){
console.log('통과.')
} else {
console.log('돌아가.')
}
=> 통과.
if(gender === 'M' && (name === 'Mike' || isAdlt)){
} else {
console.log('돌아가.')
}
=> 돌아가.
'JavaScript' 카테고리의 다른 글
switch문 (0) | 2023.03.28 |
---|---|
반복문 (0) | 2023.03.27 |
비교 연산자, 조건문(if, else) (0) | 2023.03.27 |
형변환 (0) | 2023.03.27 |
대화상자 / alert / prompt / confirm (0) | 2023.03.27 |