728x90
js에서 0 혹은 빈칸을 체크하려면 다음과 같다.
let a = 0;
let b = "";
console.log(a == 0); //true
console.log(b == 0); //true
if (b) {
console.log('b는 들어있다 !');
} else if (!b) {
// 여기가 출력!
console.log('b는 들어있지 않다. !');
}
동등연산자로 0으로 비교하면
빈칸과 0을 한번에 체크가 가능하다
'Javascript Tips' 카테고리의 다른 글
vue) 로컬에서 빌드한 index.html 라우팅 안되는 현상 (0) | 2024.02.21 |
---|---|
webpack) process.env 환경변수 설정 (0) | 2024.01.24 |
크롬 콘솔 찍히는 텍스트 색상 변경하는 법 (0) | 2023.10.18 |
Vue3 tip) this.$el.querySelector (0) | 2023.10.05 |
hands on javascript - some 연습문제 (0) | 2023.03.14 |