Home

function: dropRight


dropRight(array: Array, n: number): Array

Creates a slice of `array` with `n` elements dropped from the end.

Example(s):

dropRight([1, 2, 3])
// => [1, 2]

dropRight([1, 2, 3], 2)
// => [1]

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

dropRight([1, 2, 3], 0)
// => [1, 2, 3]

Params:

Name Type Attribute Description
array The array to query.
n The number of elements to drop.

Returns:

Array

  {
    "comment": "/**\r\n * Creates a slice of `array` with `n` elements dropped from the end.\r\n *\r\n * @since 3.0.0\r\n * @category Array\r\n * @param {Array} array The array to query.\r\n * @param {number} [n=1] The number of elements to drop.\r\n * @returns {Array} Returns the slice of `array`.\r\n * @example\r\n *\r\n * dropRight([1, 2, 3])\r\n * // => [1, 2]\r\n *\r\n * dropRight([1, 2, 3], 2)\r\n * // => [1]\r\n *\r\n * dropRight([1, 2, 3], 5)\r\n * // => []\r\n *\r\n * dropRight([1, 2, 3], 0)\r\n * // => [1, 2, 3]\r\n */",
    "meta": {
        "range": [
            530,
            717
        ],
        "filename": "dropRight.js",
        "lineno": 25,
        "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
        "code": {
            "id": "astnode100001992",
            "name": "dropRight",
            "type": "FunctionDeclaration",
            "paramnames": [
                "array",
                "n"
            ]
        },
        "vars": {
            "length": "dropRight~length",
            "n": "dropRight~n"
        }
    },
    "description": "Creates a slice of `array` with `n` elements dropped from the end.",
    "since": "3.0.0",
    "tags": [
        {
            "originalTitle": "category",
            "title": "category",
            "text": "Array",
            "value": "Array"
        }
    ],
    "params": [
        {
            "type": {
                "names": [
                    "Array"
                ]
            },
            "description": "The array to query.",
            "name": "array"
        },
        {
            "type": {
                "names": [
                    "number"
                ]
            },
            "optional": true,
            "defaultvalue": 1,
            "description": "The number of elements to drop.",
            "name": "n"
        }
    ],
    "returns": [
        {
            "type": {
                "names": [
                    "Array"
                ]
            },
            "description": "Returns the slice of `array`."
        }
    ],
    "examples": [
        "dropRight([1, 2, 3])\r// => [1, 2]\r\rdropRight([1, 2, 3], 2)\r// => [1]\r\rdropRight([1, 2, 3], 5)\r// => []\r\rdropRight([1, 2, 3], 0)\r// => [1, 2, 3]"
    ],
    "name": "dropRight",
    "longname": "dropRight",
    "kind": "function",
    "scope": "global",
    "___id": "T000002R000218",
    "___s": true,
    "filepath": "dropRight.js"
}