_.trim(移除两侧空格或指定字符)
语法:
_.trim([string=''], [chars=whitespace])
源代码链接:source
npm包链接:npm package
描述:
从string
字符串中移除前面和后面的 空格 或 指定的字符。
开始版本:3.0.0
参数:
[string=''] (string)
: 要处理的字符串。[chars=whitespace] (string)
: 要移除的字符。
返回值:
(string)
: 返回处理后的字符串。
例子:
_.trim(' abc ');
// => 'abc'
_.trim('-_-abc-_-', '_-');
// => 'abc'
_.map([' foo ', ' bar '], _.trim);
// => ['foo', 'bar']
Last updated
Was this helpful?