Realization remove whitespace string in the String prototype

String.prototype.nospace = function(){

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

} 
var str = "  hello world  ";

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

  

Guess you like

Origin www.cnblogs.com/ccyq/p/11294595.html