trim实现

可以用正则匹配空字符开头或者空字符结尾来 replace 掉

function trim(string) {
    return string.replace(/(^\s*)|(\s*$)/g, '')
}
Copyright © shaodahong 2017 all right reserved,powered by Gitbook该文件修订时间: 2017-11-04 20:32:34

results matching ""

    No results matching ""