Home

function: split


split(string: string, separator: RegExp, string, limit: number): Array

Splits `string` by `separator`. **Note:** This method is based on [`String#split`](https://mdn.io/String/split).

Example(s):

split('a-b-c', '-', 2)
// => ['a', 'b']

Params:

Name Type Attribute Description
string The string to split.
separator The separator pattern to split by.
limit The length to truncate results to.

Returns:

Array

  {
    "comment": "/**\r\n * Splits `string` by `separator`.\r\n *\r\n * **Note:** This method is based on\r\n * [`String#split`](https://mdn.io/String/split).\r\n *\r\n * @since 4.0.0\r\n * @category String\r\n * @param {string} [string=''] The string to split.\r\n * @param {RegExp|string} separator The separator pattern to split by.\r\n * @param {number} [limit] The length to truncate results to.\r\n * @returns {Array} Returns the string segments.\r\n * @example\r\n *\r\n * split('a-b-c', '-', 2)\r\n * // => ['a', 'b']\r\n */",
    "meta": {
        "range": [
            796,
            1222
        ],
        "filename": "split.js",
        "lineno": 26,
        "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
        "code": {
            "id": "astnode100008675",
            "name": "split",
            "type": "FunctionDeclaration",
            "paramnames": [
                "string",
                "separator",
                "limit"
            ]
        },
        "vars": {
            "limit": "split~limit"
        }
    },
    "description": "Splits `string` by `separator`.\r\r**Note:** This method is based on\r[`String#split`](https://mdn.io/String/split).",
    "since": "4.0.0",
    "tags": [
        {
            "originalTitle": "category",
            "title": "category",
            "text": "String",
            "value": "String"
        }
    ],
    "params": [
        {
            "type": {
                "names": [
                    "string"
                ]
            },
            "optional": true,
            "defaultvalue": "''",
            "description": "The string to split.",
            "name": "string"
        },
        {
            "type": {
                "names": [
                    "RegExp",
                    "string"
                ]
            },
            "description": "The separator pattern to split by.",
            "name": "separator"
        },
        {
            "type": {
                "names": [
                    "number"
                ]
            },
            "optional": true,
            "description": "The length to truncate results to.",
            "name": "limit"
        }
    ],
    "returns": [
        {
            "type": {
                "names": [
                    "Array"
                ]
            },
            "description": "Returns the string segments."
        }
    ],
    "examples": [
        "split('a-b-c', '-', 2)\r// => ['a', 'b']"
    ],
    "name": "split",
    "longname": "split",
    "kind": "function",
    "scope": "global",
    "___id": "T000002R000793",
    "___s": true,
    "filepath": "split.js"
}