Created
March 27, 2013 21:40
-
-
Save BenjaminAdams/5258272 to your computer and use it in GitHub Desktop.
Problem, we need to trim strings in javascript but its not implemented in all browsers Since new Browsers (IE9+) have trim() already implemented, you should only implement trim() if it is not already available on the Prototype-Object (overriding it is a huge performance hit). This is generally recommended when extending Native Objects! Note that…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!String.prototype.trim) { | |
String.prototype.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