Javascript

삼항 연산자 (ternary operator)

WEB_CREASTORY 2023. 7. 26. 15:20

condition ? expr1 : expr2

console.log(true ? "참" : "거짓") // 참
console.log(false ? "참" : "거짓") // 거짓
console.log(1 === 1 ? "참" : "거짓") // 참
console.log(1 !== 1 ? "참" : "거짓") // 거짓