Javascript String isEmpty(str)

Description

Javascript String isEmpty(str)

String.isEmpty = function(str){
    if(typeof str === 'string'){
        str = str.trim();/*w w  w.  j a  va 2 s . c om*/
    }

    switch(str){
        case "":
        case 0:
        case null:
        case false:
        case undefined:
            return true;
        default:
            return false;
    }
};



PreviousNext

Related