alert(" taobao".trim()); // 输出 "taobao" alert(" taobao ".trim()); // 输出 "taobao"
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ""); };
扫描二维码,关注牛客网
下载牛客APP,随时随地刷题