1.참,거짓 True,False
const a=1;
const b=2;
console.log(a<b); //true
console.log(a>b); //false
- if문에서
조건문이 a인 것이 참이라면 실행하라.if (a){ console.log(a) }
a의 값이 주어지지 않으면 fasle로 인식해 실행하지 않는다.const a ='' if (a){ console.log(a) }
const a = "vanilla"
if(a=="choco"){
console.log("You choose the choco")
}
else if (a=="vanilla"){
console.log("You chosse the vanilla")
}
else {
console.log("choice other tatse")
}
//You chosse the vanilla
a의 값을 지우면 else 구문을 실행한다.
'WEB > Javascript' 카테고리의 다른 글
| [JS] 기본문법 - 문자열 (0) | 2022.05.13 |
|---|---|
| [JS] 기본문법-숫자 (0) | 2022.05.05 |
| [JS] 기본문법 -함수/ 조건문/ 반복문 (0) | 2022.05.04 |
| [JS] 기본 문법 -변수 선언 (0) | 2022.05.04 |
| [JS] 자바스크립트의 개념과 기초구현 (0) | 2022.05.04 |