主题
trim
js
_.trim([string=''], [chars=whitespace])
从 string
中删除前导和尾随空格或指定字符。
¥Removes leading and trailing whitespace or specified characters from string
.
新增于
¥Since
3.0.0
参数
¥Arguments
[string='']
(字符串):要修剪的字符串。¥
[string='']
(string): The string to trim.[chars=whitespace]
(字符串):要修剪的字符。¥
[chars=whitespace]
(string): The characters to trim.
返回
¥Returns
(字符串):返回修剪后的字符串。
¥(string): Returns the trimmed string.
示例
¥Example
js
_.trim(' abc ');
// => 'abc'
_.trim('-_-abc-_-', '_-');
// => 'abc'
_.map([' foo ', ' bar '], _.trim);
// => ['foo', 'bar']