Removes leading and trailing whitespace or specified characters from `string`.
trim(' abc ')
// => 'abc'
trim('-_-abc-_-', '_-')
// => 'abc'
map([' foo ', ' bar '], trim)
// => ['foo', 'bar']
| Name | Type | Attribute | Description |
|---|---|---|---|
| string | The string to trim. | ||
| chars | The characters to trim. |
{
"comment": "/**\r\n * Removes leading and trailing whitespace or specified characters from `string`.\r\n *\r\n * @since 3.0.0\r\n * @category String\r\n * @param {string} [string=''] The string to trim.\r\n * @param {string} [chars=whitespace] The characters to trim.\r\n * @returns {string} Returns the trimmed string.\r\n * @see trimEnd, trimStart\r\n * @example\r\n *\r\n * trim(' abc ')\r\n * // => 'abc'\r\n *\r\n * trim('-_-abc-_-', '_-')\r\n * // => 'abc'\r\n *\r\n * map([' foo ', ' bar '], trim)\r\n * // => ['foo', 'bar']\r\n */",
"meta": {
"range": [
726,
1138
],
"filename": "trim.js",
"lineno": 26,
"path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
"code": {
"id": "astnode100010491",
"name": "trim",
"type": "FunctionDeclaration",
"paramnames": [
"string",
"chars"
]
},
"vars": {
"strSymbols": "trim~strSymbols",
"chrSymbols": "trim~chrSymbols",
"start": "trim~start",
"end": "trim~end"
}
},
"description": "Removes leading and trailing whitespace or specified characters from `string`.",
"since": "3.0.0",
"tags": [
{
"originalTitle": "category",
"title": "category",
"text": "String",
"value": "String"
}
],
"params": [
{
"type": {
"names": [
"string"
]
},
"optional": true,
"defaultvalue": "''",
"description": "The string to trim.",
"name": "string"
},
{
"type": {
"names": [
"string"
]
},
"optional": true,
"defaultvalue": "whitespace",
"description": "The characters to trim.",
"name": "chars"
}
],
"returns": [
{
"type": {
"names": [
"string"
]
},
"description": "Returns the trimmed string."
}
],
"see": [
"trimEnd, trimStart"
],
"examples": [
"trim(' abc ')\r// => 'abc'\r\rtrim('-_-abc-_-', '_-')\r// => 'abc'\r\rmap([' foo ', ' bar '], trim)\r// => ['foo', 'bar']"
],
"name": "trim",
"longname": "trim",
"kind": "function",
"scope": "global",
"___id": "T000002R000953",
"___s": true,
"filepath": "trim.js"
}