devSoyoung / STUDY

✏️ 공부한 내용 정리, 주제에 따라 분류
4 stars 1 forks source link

삼항연산자 줄여서 사용하기 #20

Open devSoyoung opened 5 years ago

devSoyoung commented 5 years ago
const a = 3;
const isATrue = a ? true : false;
const isATrueShort = !!a;

boolean 형태가 아닌 값의 상태를 이용해서 true/false를 얻고 싶을 때 !!를 사용할 수 있다.