Nodejs String Empty Check isEmpty()

Here you can find the source of isEmpty()

Method Source Code

/**//  ww w.  jav  a2s. c  o m
* adding isEmpy() function to the String class.
* checks whether a string is empty or contains only whitespace.
*/
String.prototype.isEmpty = function() {
    return (this.length === 0 || !this.trim());
};

Related

  1. isEmpty()
    String.prototype.isEmpty=function(){
      return this.trim()=="";
    };
    
  2. isEmpty()
    String.prototype.isEmpty = function () {
      return (!this || this == "[object Null]" || this == "" || this == "undefined");
    
  3. isEmpty()
    String.prototype.isEmpty = function() {
      return this.trim() === "";
    
  4. isEmpty()
    String.prototype.isEmpty = function(){
        return (this === null || this === '');
    };
    
  5. isEmpty()
    String.prototype.isEmpty = function() {
       return (this.length === 0 || !this.trim());
    Array.prototype.appendStringToElementAtIndex = function(index, str) {
        if(typeof this[index] === 'undefined' || typeof this[index] !== 'string') return false;
        this[index] += ' ' + str;
    };
    
  6. isEmpty()
    String.prototype.isEmpty = function(){
        if(typeof this !== 'string') {
            if(typeof this === 'object' && !(this instanceof String)){
                throw {
                    name: 'InvalidType',
                    message: 'The current type is not a String'
        return this.length === 0;
    };
    
  7. isEmpty()
    String.prototype.isEmpty = function() {
      var rtn = (this == null || this == undefined || this.trim() == '');
      return rtn;
    };
    
  8. isEmpty(pattern)
    String.prototype.isEmpty = function(pattern) {
      return this == '';
    };
    
  9. isEmpty(str)
    String.isEmpty = function(str){
        if(typeof str === 'string'){
            str = str.trim();
        switch(str){
            case "":
            case 0:
            case null:
            case false:
    ...