Nodejs String Empty Check isNullOrWhitespace()

Here you can find the source of isNullOrWhitespace()

Method Source Code

String.prototype.isNullOrWhitespace = function () {
  return this === null || this.replace(/\s/g, '').length === 0;
};

Related

  1. isNullOrEmpty()
    String.prototype.isNullOrEmpty = function() {
      return (!this || 0 === this.length || /^\s*$/.test(this));  
    };
    
  2. isNullOrEmpty()
    String.prototype.isNullOrEmpty = function(){
        return !(this && this.length > 0);
    };
    
  3. isNullOrEmpty()
    String.prototype.isNullOrEmpty = function () {
      return this === null || this.length === 0;
    };
    
  4. isNullOrEmptyString(obj)
    function isNullOrEmptyString(obj) {
      if (isNullOrUnderdefined(obj))
        return false;
      if (isStringType(obj)) {
        return obj.length == 0;
      return false;
    
  5. isNullOrWhitespace(input)
    String.isNullOrWhitespace = function( input ) {
      return !input || !input.trim();
    };
    
  6. isEmpty()
    String.prototype.isEmpty = function() {
      return this == '';
    };
    
  7. isEmpty()
    String.prototype.isEmpty = function() {
        return (this.length === 0 || !this.trim());
    };
    
  8. isEmpty()
    "use strict";
    String.prototype.isEmpty = function() {
        return (this.length === 0 || !this.trim());
    };