JavaScript实现String的trim函数

2019PHP高薪工程师学习路线图....>>>


String.prototype.trim = function(){
    return this.replace(/(^[\\s]*)|([\\s]*$)/g, "");
}
String.prototype.lTrim = function(){
    return this.replace(/(^[\\s]*)/g, "");
}
String.prototype.rTrim = function(){
    return this.replace(/([\\s]*$)/g, "");
}