javascript如何实现去除空格

以下是javascript实现的去除空格函数,代码如下:
<SCRIPT LANGUAGE="JavaScript">
<!--
//出处:网上搜集
//made by yaosansi 2005-12-02
// Trim() , Ltrim() , RTrim() 
String.prototype.Trim = function() 
{ 
return this.replace(/(^\s*)|(\s*$)/g, ""); 
} 
 
String.prototype.LTrim = function() 
{ 
return this.replace(/(^\s*)/g, ""); 
} 
 
String.prototype.RTrim = function() 
{ 
return this.replace(/(\s*$)/g, ""); 
} 
 
//-->
</SCRIPT>