davej Posted December 31, 2012 Share Posted December 31, 2012 Anyone happen to know if all the recent browsers now support .trim() for strings? Thanks Link to comment Share on other sites More sharing options...
jeffman Posted January 1, 2013 Share Posted January 1, 2013 You might find this useful. Link to comment Share on other sites More sharing options...
davej Posted January 1, 2013 Author Share Posted January 1, 2013 (edited) You might find this useful. Oh, it has a table: Firefox (Gecko) 3.5Chrome (Yes) Internet Explorer 9Opera 10.5Safari 5 Edited January 1, 2013 by davej Link to comment Share on other sites More sharing options...
justsomeguy Posted January 7, 2013 Share Posted January 7, 2013 There's also a prototype for trim you can add to give support to browsers that don't already have it. Link to comment Share on other sites More sharing options...
davej Posted January 7, 2013 Author Share Posted January 7, 2013 Well, I wrote a trim function a few years ago but then the other day I was lazy and just tacked on .trim() like you would in most languages, and it worked. So I don't really know what to do, but then I'm not really working on anything that matters right now. Link to comment Share on other sites More sharing options...
justsomeguy Posted January 7, 2013 Share Posted January 7, 2013 Add the String.prototype.trim function in the manual to your code, and always use String.trim. If the browser supports it natively then it will use the native version, or else it will use the version you defined. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now