Js to remove the space of the string of the implementation code

  • 2020-03-29 23:52:09
  • OfStack

1. Remove Spaces from both ends of the string

String. The prototype. The trim = function () {return this. The replace (/ (^ / s *) | ($)/s * / g, "); }

2. Remove all Spaces in the string:
 
String.proto.strim = function (){return this.replace(//s/g, '); }

Or:


Related articles: