Write your own js like trim method


Since the trim method of JS is not supported in many browsers, we can use our own trim method here to deal with the need to cut out the empty strings at both ends of the string


String.prototype.trim = function () {
return this .replace(/^ss*/, '' ).replace(/ss*$/, '');
}