Skip to content

Instantly share code, notes, and snippets.

@glava
Created January 22, 2014 16:44
Show Gist options
  • Save glava/8562207 to your computer and use it in GitHub Desktop.
Save glava/8562207 to your computer and use it in GitHub Desktop.
Adding trim to any string
Function.prototype.method = function (name, func) {
this.prototype[name] = func;
return this;
};
String.method('trim', function () {
return this.replace(/^\s+|\s+$/g, '');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment