Javascript String diyTrim()

Description

Javascript String diyTrim()


String.prototype.diyTrim = function() {
  var copy = this;
  return copy.replace(/^\s+|\s+$/g, "");
};
console.log("  Test   ".diyTrim());



PreviousNext

Related