Skip to content

Instantly share code, notes, and snippets.

@gr2m
Created April 26, 2010 19:41
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 gr2m/379779 to your computer and use it in GitHub Desktop.
Save gr2m/379779 to your computer and use it in GitHub Desktop.
trim() function for Strings
// add trim to String Object
String.prototype.trim = function() {
return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment