Home

function: flatten


flatten(array: Array): Array

Flattens `array` a single level deep.

Example(s):

flatten([1, [2, [3, [4]], 5]])
// => [1, 2, [3, [4]], 5]

Params:

Name Type Attribute Description
array The array to flatten.

Returns:

Array

  {
    "comment": "/**\r\n * Flattens `array` a single level deep.\r\n *\r\n * @since 0.1.0\r\n * @category Array\r\n * @param {Array} array The array to flatten.\r\n * @returns {Array} Returns the new flattened array.\r\n * @see flatMap, flatMapDeep, flatMapDepth, flattenDeep, flattenDepth\r\n * @example\r\n *\r\n * flatten([1, [2, [3, [4]], 5]])\r\n * // => [1, 2, [3, [4]], 5]\r\n */",
    "meta": {
        "range": [
            403,
            528
        ],
        "filename": "flatten.js",
        "lineno": 16,
        "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
        "code": {
            "id": "astnode100002637",
            "name": "flatten",
            "type": "FunctionDeclaration",
            "paramnames": [
                "array"
            ]
        },
        "vars": {
            "length": "flatten~length"
        }
    },
    "description": "Flattens `array` a single level deep.",
    "since": "0.1.0",
    "tags": [
        {
            "originalTitle": "category",
            "title": "category",
            "text": "Array",
            "value": "Array"
        }
    ],
    "params": [
        {
            "type": {
                "names": [
                    "Array"
                ]
            },
            "description": "The array to flatten.",
            "name": "array"
        }
    ],
    "returns": [
        {
            "type": {
                "names": [
                    "Array"
                ]
            },
            "description": "Returns the new flattened array."
        }
    ],
    "see": [
        "flatMap, flatMapDeep, flatMapDepth, flattenDeep, flattenDepth"
    ],
    "examples": [
        "flatten([1, [2, [3, [4]], 5]])\r// => [1, 2, [3, [4]], 5]"
    ],
    "name": "flatten",
    "longname": "flatten",
    "kind": "function",
    "scope": "global",
    "___id": "T000002R000285",
    "___s": true,
    "filepath": "flatten.js"
}