js 去除字符串中的空格

去除字符串首尾空格方法:

str.trim()

去除字符串首尾及中间空格方法:
let str = '   a  b  c '
str = str.replace(/\s*/g,'')
console.log(str)
posted @ 2019-06-20 15:40  叶子玉  阅读(4245)  评论(0编辑  收藏  举报