String.trim Function
Removes leading and trailing white-space characters from a String object.
var trimmedStringVar = myString.trim();
Return Value
A copy of the string with all white-space characters removed from the start and end of the string.
Remarks
Use the trim function to remove leading and trailing white-space characters from the current String object. Examples of white-space characters are spaces and tabs.
Example
The following example shows how to use the trim function to remove leading and trailing white space from a String object.