yesJames.com
ahuh… sure… what ever you say…


JavaScript Trim() function

Posted in JavaScript,programming by james on March 20th, 2008

Trim(), is one function that we all use almost every day in most languages, whether it’s a core function of the language you’re using or a member (or prototype in JavaScript) function of the String object itself (as in C#), it’s invaluable for developers.

Unfortunately JavaScript doesn’t have this sort of thing built in, so here’s how to implement your own trim() functions (as well as ltrim() and rtrim()) in various ways depending on the level of backward compatibility you require.

(more…)