Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript validate if string null undefined empty

/**
  * Checks the string if undefined, null, not typeof string, empty or space(s)
  * @param {any} str string to be evaluated
  * @returns {boolean} the evaluated result
*/
function isStringNullOrWhiteSpace(str) {
    return str === undefined || str === null
                             || typeof str !== 'string'
                             || str.match(/^ *$/) !== null;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #validate #string #null #undefined #empty
ADD COMMENT
Topic
Name
9+7 =