用JS编写一个函数trim(str),用于去除指定字符串中所有空格,例如:”a b cd”结果为”abcd”

2025-04-07 06:38:58
推荐回答(1个)
回答1:

function trim(s){return s.replace(/^\s+|\s+$/g,"");};