JavaScript judgment is empty

 

//     var A = "";
 //     var A = "";
 //     var A = null;
 //     var A = undefined;
 //     var A = [];
 //     var A = {};
 //     var A NaN3 =; 
    
    iF (a === undefined) { // only use the === to test whether a value is undefined 
        the console.log ( " is undefined " ); 
    } 
    iF (a == null ) { // equivalent to undefined || === A === A null 
        the console.log ( " is null " ); 
    } 
    // String     
    IF (A =="" || a == null || a == undefined){ // "",null,undefined
        console.log("为空");
    }
    if(!a){ // "",null,undefined,NaN
        console.log("为空"); 
    }
    if(!$.trim(a)){ // "",null,undefined
        console.log("为空");
    }
    // Array
    if(a.length == 0){ // "",[]
        console.log(""Empty); 
    } 
    IF (a.length) {! // "", [] 
        the console.log ( " empty " ); 
    } 
    // Object} { 
    IF ($ .isEmptyObject (A)) { // Common Object used for ... in judgment, there is the key to false 
        the console.log ( " empty " ); 
    }

 

Guess you like

Origin www.cnblogs.com/sea-stream/p/11100392.html