/ Published in: JavaScript
![](/img/icon_sav.png?v3)
Add trim method to String class
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };
Comments
![RSS Feed for Comments RSS Icon](/images/rss.png?v3)
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };