Nodejs String Empty Check isBlank()

Here you can find the source of isBlank()

Method Source Code

String.prototype.isBlank = function() {
    if (this.trim().length == 0)
        return true;
    else/*from   w  w  w .j  a  v a2  s  . co m*/
        return false;
};

/**
 * Subtract hours from UTC time to preserve time after time zone
 * conversion when sending it to the server in AJAX request.
 *
 * Here is the problem: script service proxy converts times
 * from UTC to local time zone after receining JSON response.
 * But we want to it to stay the same time as on the server.
 * Applying this function will revert effect of time zone conversion.
 */

Date.prototype.toLocalDate = function() {
    var localTime = this.getTime();
    var localOffset = this.getTimezoneOffset() * 60000;
    return new Date(localTime - localOffset);
};

Related

  1. isEmpty(str)
    String.isEmpty = function(str){
        if(typeof str === 'string'){
            str = str.trim();
        switch(str){
            case "":
            case 0:
            case null:
            case false:
    ...
    
  2. isBlank()
    String.prototype.isBlank = function() { 
      return !this.match(/\S/) 
    
  3. isBlank()
    String.prototype.isBlank = function() {
      return (!this || /^\s*$/.test(this));
    };
    
  4. isBlank()
    String.prototype.isBlank = function() {
        return (this==null || this=="");
    
  5. isBlank()
    String.prototype.isBlank = function (){
      var str = $.trim(this);
      if(str == "") {
        return true;
      } else {
        return false;
    
  6. isBlank()
    String.prototype.isBlank = function() {
        if (this == undefined || this == "" || this == null || /^\s*$/.test(this)) {
            return true;
        return false;
    };
    
  7. isBlank()
    String.prototype.isBlank = function()
      try
        var value = this.toString().trim();
        if (value == null) return true;
          if (value.length == 0)
            return true;
          else
    ...
    
  8. isBlank(pattern)
    String.prototype.isBlank = function(pattern) {
      return /^\s*$/.test(this);
    };