标签:模拟 prototype 测试 his return turn lan lang pre
function trim() {
let reg = /(^\s*)|(\s*$)/g
let res = this.replace(reg, ‘‘)
return res
}
String.prototype.trim = trim
// 测试
let str = ‘ hello word ‘
console.log(str.trim())
// "hello word"
标签:模拟 prototype 测试 his return turn lan lang pre
原文地址:https://www.cnblogs.com/liea/p/12627792.html