關於null,undefined,空字符串的判斷

<script>
    let a=xxx;
    if (!a && typeof a=="object") {
        alert('a是一個null');
    }else if(!a && typeof a=="undefined"){
        alert('a是undefined')
    }else if(!a && typeof a=='string'){
        alert('a是一個空字符串')
    }else{
        alert('其它')
    }
</script>
相關文章
相關標籤/搜索