JavaScript--判断字符是否为空

js代码:

//判断字符是否为空的方法
function IsEmpty(res){
    if(typeof res== "undefined" || res== null || res== ""){
        return true;
    }else{
        return false;
    }
}

js调用:

if (!IsEmpty(value)) {
    alert(value);
}

 

posted @ 2019-08-21 08:48  初晨~  阅读(689)  评论(0编辑  收藏  举报