JS determines whether the string is empty

Be the main front-end back-end Daza write chirp cry

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");
}

  

Guess you like

Origin www.cnblogs.com/zlrrrr/p/11465940.html