JavaScript trim function: Trimming a String in JavaScript

JavaScript does not have a native trim function. Creating a trim function for use in JavaScript is not difficult, however.
Example:
function trim(value)
{
//Takes any spaces at the front of the string (^)
//or (’|’) at the end of the string ($)
//and replaces them with an empty string
var strValue = value.replace(/^\s+|\s+$/,'');
return strValue;
}
var TrimThis = ' JavaScript trim [...]