用JS兑现去掉空格功能

用JS实现去掉空格功能//去两边空格String.prototype.trim function(){return this.replace(/(^\s*)|(\s*

用JS实现去掉空格功能
//去两边空格  
    String.prototype.trim = function(){  
        return this.replace(/(^\s*)|(\s*$)/g, "");  
    };  
//去所有空格  
String.prototype.trimAll = function(){  
return this.replace(/(^\s*)|(\s*)|(\s*$)/g, "");  
};