Javascript String blank(pattern)

Description

Javascript String blank(pattern)


/**/*from  w  w w  . j av  a2s . c  om*/
 *  String#blank() -> Boolean
 *
 *  Check if the string is "blank" — either empty (length of `0`) or
 *  containing only whitespace.
 *
 *  ##### Example
 *
 *      ''.blank();
 *      //-> true
 *
 *      '  '.blank();
 *      //-> true
 *
 *      ' a '.blank();
 *      //-> false
**/
String.prototype.blank = function(pattern) {
  return /^\s*$/.test(this);
};



PreviousNext

Related