728x90
반응형
빈칸(""), null, 공백(" ")을 체크하는 메소드
*자세한 설명 생략
/**
* Null Check
*
* @param {*} str
* @returns default false
*/
function nullCheck(str) {
if ("" == str) { return true }
if (null == str) { return true }
if (str.replace(/\s/g, '').length < 1) { return true }
return false
}
*개선한 버전
/**
* isBlank Check
*
* @param {*} str
* @returns {boolean}
*/
function isBlank(str) {
return !str || str.trim().length === 0;
}
728x90
728x90
'▶ Front-End > Javascript' 카테고리의 다른 글
Start to Last Date (0) | 2023.11.14 |
---|---|
Date Formater (0) | 2023.11.14 |
댓글