标签:截取 on() replace prototype trim 例子 string type ons
String.prototype.trim = function(){
return this.replace(/(^\s*)|(\s*$)/g,‘‘);
}
例子:
var test = " abc ";
String.prototype.trim = function(){
return this.replace(/(^\s*)|(\s*$)/g,‘‘);
}
test = test.trim();
console.log(test);
标签:截取 on() replace prototype trim 例子 string type ons
原文地址:http://www.cnblogs.com/wongh/p/7670155.html