String.prototype.trim = function(){ return this.replace(/(^/s*)|(/s*$)/g, "");} //给string添加了一个属性方法,该方法用于去除掉string中首尾的空白字符。