企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## 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'] ```