Javascript String isNullOrWhitespace()

Description

Javascript String isNullOrWhitespace()


/**//from  ww w  . j av a 2s.c o  m
 * Checks if the string is empty, whitespace or null
 */
String.prototype.isNullOrWhitespace = function () {
    try {
        var str = this.toString();

        return this === '' || this === null;
    }
    catch(err) {
        return false;
    }
}



PreviousNext

Related