컴퓨터 Javascript isNullOrEmpty
2020.11.25 23:43
값이 null, undefined, NaN, 빈 문자열, 빈 오브젝트 등을 체크
/**
* @param any value : null 값 검사할 Input 변수
* @return boolean true = null, false = not null
*/
function isNullOrEmpty(value) {
var returnValue = false;
try{
if(
((value != 0) & !value)
|| (typeof(value) == "undefined")
|| value == null
|| (typeof(value) == "object" && Object.prototype.toString.call(value) != "[object Date]" && !Object.keys(value).length)
|| (typeof(value) == "string" && value.trim() == "")
|| (typeof(value) == "number" && isNaN(value))
)
{
returnValue = true;
}
}catch(e)
{
returnValue = false;
}
return returnValue;
}






