Nodejs String Empty Check isBlank()

Here you can find the source of isBlank()

Method Source Code

String.prototype.isBlank = function()
{
   try//from   w w  w  . ja va 2s. co  m
   {
      var value = this.toString().trim();

      // Validate is null
      if (value == null) return true;

      // Validate by length
       if (value.length == 0)
          return true;
       else
          return false;
   }
   catch(err)
   {
      return false;
   }
};

Related

  1. isBlank()
    String.prototype.isBlank = function() {
      return (!this || /^\s*$/.test(this));
    };
    
  2. isBlank()
    String.prototype.isBlank = function() {
        return (this==null || this=="");
    
  3. isBlank()
    String.prototype.isBlank = function (){
      var str = $.trim(this);
      if(str == "") {
        return true;
      } else {
        return false;
    
  4. 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;
    ...
    
  5. isBlank()
    String.prototype.isBlank = function() {
        if (this == undefined || this == "" || this == null || /^\s*$/.test(this)) {
            return true;
        return false;
    };
    
  6. isBlank(pattern)
    String.prototype.isBlank = function(pattern) {
      return /^\s*$/.test(this);
    };