Javascript String blank()

Description

Javascript String blank()


String.prototype.blank = function() {
  return /^\s*$/.test(this);
};

Javascript String blank()

String.prototype.blank = function() {
  return !(this.replace(/\s+/g, "").length)
}

Javascript String blank()

String.prototype.blank = function(){
  return this.length === 0 || this.indexOf(" ") === 0 && this.length ===1;
};

Javascript String blank()

String.prototype.blank = function(){
 //return (this === " " || this === "");
  var that = this.split("");
  return that.every(function(elem){
    return elem === " ";
  }) || this === "";

};


//console.log("  ".blank());

Javascript String blank()

String.prototype.blank = function () {
    return !(this.
        split("").
        some(function (a) {
            return a !== " ";
        }));//from  w  w  w .ja  va2  s  .  c o  m

};

Javascript String blank()

String.prototype.blank = function() {
  return this.replace(/\s+/g, '').length == 0 ? true : false;
};



PreviousNext

Related