1. 산술연산자
document.write(5+3); //8
document.write(5-3); //2
document.write(5*3); //15
document.write(5/3); //1.66666 (몫)
document.write(5%3); //2 (나머지)
document.write(3/5); //0.6
document.write(3%5); //3
2. 비교(관계)연산자
-> 논리형(boolean)으로 반환된다. (true/false)
document.write(5>3); //true
document.write(5<3); //false
document.write(5>=3); //true
document.write(5<=3); //false
document.write(5==3); //false (== 서로같다)
document.write(5!=3); //true (!= 서로 같지않다)
3. 논리연산자
1) && 연산자
-> 그리고, and 연산자, 논리곱
-> 모든 조건이 true일 때만 true
-> ~이면서
document.write(5<3 && 2<4); //false + true = false
2) || 연산자
-> 또는, or 연산자, 논리합
-> 조건들 중에서 하나만이라도 true이면 true
-> ~이거나
document.write(5<3 || 2<4); //false + true = true
3) ! 연산자
-> 논리 부정 연산자, not 연산자
-> ~아니라면
let flag=true;
document.write(!flag); //false
'JavaScript' 카테고리의 다른 글
| [JS] 연산자 (0) | 2024.06.02 |
|---|---|
| [JS] 연산자 연습문제 (0) | 2024.06.01 |
| [JS] document (0) | 2024.06.01 |
| [JS] 변수 (0) | 2024.06.01 |
| [JS] 출력 (0) | 2024.06.01 |