服务器

Array

Collection

Date

Function

Lang

Math

Number

Object

Seq

String

Util

Properties

Methods

_.trim(string='', chars=whitespace)

从中删除前导和尾部的空格或指定的字符string

版本

3.0.0

参数
  1. [string=''] (字符串):要修剪的字符串。
  2. [chars=whitespace] (字符串):要修剪的字符。
返回

(字符串):返回修剪后的字符串。

_.trim('  abc  ');
// => 'abc'
 
_.trim('-_-abc-_-', '_-');
// => 'abc'
 
_.map(['  foo  ', '  bar  '], _.trim);
// => ['foo', 'bar']