Nodejs String Empty Check isBlank(pattern)

Here you can find the source of isBlank(pattern)

Method Source Code

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

Related

  1. isBlank()
    String.prototype.isBlank = function() {
        return (this==null || this=="");
    
  2. isBlank()
    String.prototype.isBlank = function (){
      var str = $.trim(this);
      if(str == "") {
        return true;
      } else {
        return false;
    
  3. isBlank()
    String.prototype.isBlank = function() {
        if (this.trim().length == 0)
            return true;
        else
            return false;
    };
    Date.prototype.toLocalDate = function() {
        var localTime = this.getTime();
        var localOffset = this.getTimezoneOffset() * 60000;
    ...
    
  4. isBlank()
    String.prototype.isBlank = function() {
        if (this == undefined || this == "" || this == null || /^\s*$/.test(this)) {
            return true;
        return false;
    };
    
  5. isBlank()
    String.prototype.isBlank = function()
      try
        var value = this.toString().trim();
        if (value == null) return true;
          if (value.length == 0)
            return true;
          else
    ...