Skip to content

Instantly share code, notes, and snippets.

@marcelo-ribeiro
Last active September 3, 2018 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcelo-ribeiro/23f775805f97a301febc3b133200d3da to your computer and use it in GitHub Desktop.
Save marcelo-ribeiro/23f775805f97a301febc3b133200d3da to your computer and use it in GitHub Desktop.
Trim All White Spaces
(function () {
if (!String.prototype.trimAll) {
String.prototype.trimAll = function () {
return this.replace(/\s+/g, '');
};
}
})();
// Example
console.log(' Hello World '.trimAll());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment