Javascript String isEmpty()

Description

Javascript String isEmpty()


function isEmpty(str) {
  return (!str || 0 === str.length);
}

function isBlank(str) {
  return (!str || /^\s*$/.test(str));
}

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

Javascript String isEmpty()

String.prototype.isEmpty = function() {
  return this == '';
};

Javascript String isEmpty()

// Check for an empty string.
String.prototype.isEmpty = function() {
  return this.length === 0 || !this.trim();
};

Javascript String isEmpty()

String.prototype.isEmpty = function() {
    return this == null || this == '';
};

RegExp.escape = function(val) {
    return val.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
};

Javascript String isEmpty()

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

Javascript String isEmpty()

String.prototype.isEmpty = function() {
 return this.toString().trim() == "";
};

Javascript String isEmpty()

String.prototype.isEmpty = function() {
  return (this == '');
};
String.prototype.contains = function(it) {
  if (it instanceof Array) {
    for (var i in it) {
      if (this.indexOf(it[i]) != -1)
 return true; //ww  w.j a  v  a2  s .c o  m
    }
    return false;
  }
  else
    return this.indexOf(it) != -1;
};

Javascript String isEmpty()

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

Javascript String isEmpty()

String.prototype.isEmpty = function () {
 return this.Trim().length == 0;
};

Javascript String isEmpty()

// Where to put utility?
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;
};

Javascript String isEmpty()

String.prototype.isEmpty = function () {
 return (!this || this == "[object Null]" || this == "" || this == "undefined");
}

Javascript String isEmpty()

String.prototype.isEmpty = function(){
 var str = this;/*from   ww  w .j  av  a2  s  .  co  m*/
 return str == '';
}

String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g, '');};

Array.prototype.contains = function(obj) {
    var i = this.length;
    while (i--) {
        if (this[i] == obj) {
            return true;
        }
    }
    return false;
}

Javascript String isEmpty()

String.prototype.isEmpty = function() {
  return this.trim() === "";
}



PreviousNext

Related