function removeSpaces(str) {
return str.replace(/\s+/g, '');
}
// 示例用法
const str = " hello world ";
console.log(removeSpaces(str)); // 输出: "helloworld"
js 去除空格
最新推荐文章于 2025-06-09 21:53:43 发布
function removeSpaces(str) {
return str.replace(/\s+/g, '');
}
// 示例用法
const str = " hello world ";
console.log(removeSpaces(str)); // 输出: "helloworld"