JS 判断字符串是否为空

打杂的 Be 主前端后端都写 哭唧唧

function isEmpty(str) {
    if(typeof str== null || str== "" || str== "undefined") {
        return true;
    } else {
        return false;
    }
}

  

if(isEmpty(ind_vue.params.userId)) {
    console.log("userId");
}
if(isEmpty(ind_vue.params.dayStart)) {
    console.log("dayStart");
}
if(isEmpty(ind_vue.params.dayEnd)) {
    console.log("dayEnd");
}
if(isEmpty(ind_vue.params.timeStart)) {
    console.log("timeStart");
}
if(isEmpty(ind_vue.params.timeEnd)) {
    console.log("timeEnd");
}

  

posted @ 2019-09-05 14:47  丧心病狂工科女  阅读(7861)  评论(2编辑  收藏  举报