WEB/Javascript
[JS] 기본문법-boolean
탱!
2022. 5. 4. 15:32
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 구문을 실행한다.