trim
最后更新于:2022-04-02 00:07:42
## trim
+ [link](./trim "Link to this entry.")
+ [source](https://github.com/lodash/lodash/blob/4.5.0正式版/lodash.src.js#L12821 "View in source.")
+ [npm](https://www.npmjs.com/package/lodash.trim "See the npm package.")
```
_.trim([string=''], [chars=whitespace])
```
从字符串中移除前面和后面的空白 或 指定的字符。
### 参数
1. [string=''] (string)
要处理的字符串
2. [chars=whitespace] (string)
要处理的字符
### 返回值 (string)
返回处理后的字符串
### 示例
```
_.trim(' abc ');
// => 'abc'
_.trim('-_-abc-_-', '_-');
// => 'abc'
_.map([' foo ', ' bar '], _.trim);
// => ['foo', 'bar']
```
';