This little peice of ingenious code builds on the protype to add trim() functionality to strings, thus trimming whitespace from either the left, right, or both sides of the string.
example of usage:
var sOriginal=' text ';
sTrim = sOriginal.trim();
sLTrim=sOriginal.ltrim();
sRTrim=sOriginal.rtrim();
After execution:
sOriginal is ' text '
sTrim is 'text'
sLTrim is 'text '
sRTrim is ' text'
Found this years ago on the web - can't remember where..
Added by JC on 12th November, 2007
There are no comments about this snippet.
You must be registered and logged in to post a comment.
Login here to post a comment