[Js] 빈문자열 체크

해나·2024년 2월 17일
0
post-thumbnail

빈 문자열을 체크할 때

const str = ""

if(str=="") console.log("빈문자열")

나도 모르게 str==""로 빈문자열인지 체크하고 있었다.

const str = ""

console.log(!str&&"빈문자열")

!str로 빈문자열인지 쉽게 체크하자.

kotlin 썼다가 js 썼다가 왔다갔다 하니까 isEmpty가 js에 있는줄알고 isEmpty를 쓰고있는 나를 발견했다.ㅜㅜ
profile
hena.log("Markdown STH")

0개의 댓글

Powered by GraphCDN, the GraphQL CDN