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: