Javascript String newTrim()

Description

Javascript String newTrim()


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

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

var str = 'aa';
console.log(str.newTrim());/*from  w  w w .  j  ava 2s  . com*/



PreviousNext

Related