函数:
function strTrim(str){
if(!String.prototype.trim){
return str.replace(/^\s+/,'').replace(/\s+$/,'');
}else{
str.trim();
}
}
调用:
console.log(strTrim(' a b c '));
结果:
a b c
函数:
function strTrim(str){
if(!String.prototype.trim){
return str.replace(/^\s+/,'').replace(/\s+$/,'');
}else{
str.trim();
}
}
调用:
console.log(strTrim(' a b c '));
结果:
a b c