在String的原型上实现去掉字符串中的空白字符

String.prototype.nospace = function(){

    return this.replace(/\s/g,"")

} 
var str = "  hello world  ";

console.log(str.nospace());  //helloworld

  

猜你喜欢

转载自www.cnblogs.com/ccyq/p/11294595.html
今日推荐