Home

function: toArray


toArray(value: *): Array

Converts `value` to an array.

Example(s):

toArray({ 'a': 1, 'b': 2 })
// => [1, 2]

toArray('abc')
// => ['a', 'b', 'c']

toArray(1)
// => []

toArray(null)
// => []

Params:

Name Type Attribute Description
value The value to convert.

Returns:

Array

  {
    "comment": "/**\r\n * Converts `value` to an array.\r\n *\r\n * @since 0.1.0\r\n * @category Lang\r\n * @param {*} value The value to convert.\r\n * @returns {Array} Returns the converted array.\r\n * @example\r\n *\r\n * toArray({ 'a': 1, 'b': 2 })\r\n * // => [1, 2]\r\n *\r\n * toArray('abc')\r\n * // => ['a', 'b', 'c']\r\n *\r\n * toArray(1)\r\n * // => []\r\n *\r\n * toArray(null)\r\n * // => []\r\n */",
    "meta": {
        "range": [
            999,
            1403
        ],
        "filename": "toArray.js",
        "lineno": 39,
        "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
        "code": {
            "id": "astnode100009746",
            "name": "toArray",
            "type": "FunctionDeclaration",
            "paramnames": [
                "value"
            ]
        },
        "vars": {
            "tag": "toArray~tag",
            "func": "toArray~func"
        }
    },
    "description": "Converts `value` to an array.",
    "since": "0.1.0",
    "tags": [
        {
            "originalTitle": "category",
            "title": "category",
            "text": "Lang",
            "value": "Lang"
        }
    ],
    "params": [
        {
            "type": {
                "names": [
                    "*"
                ]
            },
            "description": "The value to convert.",
            "name": "value"
        }
    ],
    "returns": [
        {
            "type": {
                "names": [
                    "Array"
                ]
            },
            "description": "Returns the converted array."
        }
    ],
    "examples": [
        "toArray({ 'a': 1, 'b': 2 })\r// => [1, 2]\r\rtoArray('abc')\r// => ['a', 'b', 'c']\r\rtoArray(1)\r// => []\r\rtoArray(null)\r// => []"
    ],
    "name": "toArray",
    "longname": "toArray",
    "kind": "function",
    "scope": "global",
    "___id": "T000002R000897",
    "___s": true,
    "filepath": "toArray.js"
}