trim

String
since 3.0.0

Arguments

  • string The string to trim.
  • string The characters to trim.

Returns

string the trimmed string.

Removes leading and trailing whitespace or specified characters from string.

Example of Lodash _.trim

_.trim('  abc  ');
// => 'abc'

_.trim('-_-abc-_-', '_-');
// => 'abc'

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