String.prototype.trim = function () {
let reg = /(^s*)|(s*$)/g
return this.replace(reg, '')
}
// 测试
let str = ' hello word '
console.log(str.trim())
// "hello word"
String.prototype.trim = function () {
let reg = /(^s*)|(s*$)/g
return this.replace(reg, '')
}
// 测试
let str = ' hello word '
console.log(str.trim())
// "hello word"