1. 程式人生 > >關於null,undefined,空字符串的判斷

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

null ack type 字符 ring 字符串 判斷 undefine object

<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
>

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