Nodejs String Empty Check isEmpty()

Here you can find the source of isEmpty()

Method Source Code

"use strict";/*from w  w w .ja  v  a  2  s  . co  m*/

String.prototype.isEmpty = function() {
    return (this.length === 0 || !this.trim());
};

Related

  1. isNullOrEmptyString(obj)
    function isNullOrEmptyString(obj) {
      if (isNullOrUnderdefined(obj))
        return false;
      if (isStringType(obj)) {
        return obj.length == 0;
      return false;
    
  2. isNullOrWhitespace()
    String.prototype.isNullOrWhitespace = function () {
      return this === null || this.replace(/\s/g, '').length === 0;
    };
    
  3. isNullOrWhitespace(input)
    String.isNullOrWhitespace = function( input ) {
      return !input || !input.trim();
    };
    
  4. isEmpty()
    String.prototype.isEmpty = function() {
      return this == '';
    };
    
  5. isEmpty()
    String.prototype.isEmpty = function() {
        return (this.length === 0 || !this.trim());
    };
    
  6. isEmpty()
    String.prototype.isEmpty = function() {
      return this.length === 0 || !this.trim();
    };
    
  7. isEmpty()
    String.prototype.isEmpty = function() {
        return this == null || this == '';
    };
    RegExp.escape = function(val) {
        return val.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
    };
    
  8. isEmpty()
    String.prototype.isEmpty = function() { 
      return (!this.length) 
    
  9. isEmpty()
    String.prototype.isEmpty = function() {
      return this.toString().trim() == "";
    };