Splits `string` into an array of its words.
words('fred, barney, & pebbles')
// => ['fred', 'barney', 'pebbles']
words('fred, barney, & pebbles', /[^, ]+/g)
// => ['fred', 'barney', '&', 'pebbles']
| Name | Type | Attribute | Description |
|---|---|---|---|
| string | The string to inspect. | ||
| pattern | The pattern to match words. |
{
"comment": "/**\r\n * Splits `string` into an array of its words.\r\n *\r\n * @since 3.0.0\r\n * @category String\r\n * @param {string} [string=''] The string to inspect.\r\n * @param {RegExp|string} [pattern] The pattern to match words.\r\n * @returns {Array} Returns the words of `string`.\r\n * @example\r\n *\r\n * words('fred, barney, & pebbles')\r\n * // => ['fred', 'barney', 'pebbles']\r\n *\r\n * words('fred, barney, & pebbles', /[^, ]+/g)\r\n * // => ['fred', 'barney', '&', 'pebbles']\r\n */",
"meta": {
"range": [
751,
974
],
"filename": "words.js",
"lineno": 27,
"path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
"code": {
"id": "astnode100011677",
"name": "words",
"type": "FunctionDeclaration",
"paramnames": [
"string",
"pattern"
]
},
"vars": {
"result": "words~result"
}
},
"description": "Splits `string` into an array of its words.",
"since": "3.0.0",
"tags": [
{
"originalTitle": "category",
"title": "category",
"text": "String",
"value": "String"
}
],
"params": [
{
"type": {
"names": [
"string"
]
},
"optional": true,
"defaultvalue": "''",
"description": "The string to inspect.",
"name": "string"
},
{
"type": {
"names": [
"RegExp",
"string"
]
},
"optional": true,
"description": "The pattern to match words.",
"name": "pattern"
}
],
"returns": [
{
"type": {
"names": [
"Array"
]
},
"description": "Returns the words of `string`."
}
],
"examples": [
"words('fred, barney, & pebbles')\r// => ['fred', 'barney', 'pebbles']\r\rwords('fred, barney, & pebbles', /[^, ]+/g)\r// => ['fred', 'barney', '&', 'pebbles']"
],
"name": "words",
"longname": "words",
"kind": "function",
"scope": "global",
"___id": "T000002R001057",
"___s": true,
"filepath": "words.js"
}