Creates a slice of `array` with `n` elements taken from the end.
takeRight([1, 2, 3])
// => [3]
takeRight([1, 2, 3], 2)
// => [2, 3]
takeRight([1, 2, 3], 5)
// => [1, 2, 3]
takeRight([1, 2, 3], 0)
// => []
Name | Type | Attribute | Description |
---|---|---|---|
array | The array to query. | ||
n | The number of elements to take. |
{ "comment": "/**\r\n * Creates a slice of `array` with `n` elements taken 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 take.\r\n * @returns {Array} Returns the slice of `array`.\r\n * @example\r\n *\r\n * takeRight([1, 2, 3])\r\n * // => [3]\r\n *\r\n * takeRight([1, 2, 3], 2)\r\n * // => [2, 3]\r\n *\r\n * takeRight([1, 2, 3], 5)\r\n * // => [1, 2, 3]\r\n *\r\n * takeRight([1, 2, 3], 0)\r\n * // => []\r\n */", "meta": { "range": [ 528, 720 ], "filename": "takeRight.js", "lineno": 25, "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo", "code": { "id": "astnode100008993", "name": "takeRight", "type": "FunctionDeclaration", "paramnames": [ "array", "n" ] }, "vars": { "length": "takeRight~length", "n": "takeRight~n" } }, "description": "Creates a slice of `array` with `n` elements taken 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 take.", "name": "n" } ], "returns": [ { "type": { "names": [ "Array" ] }, "description": "Returns the slice of `array`." } ], "examples": [ "takeRight([1, 2, 3])\r// => [3]\r\rtakeRight([1, 2, 3], 2)\r// => [2, 3]\r\rtakeRight([1, 2, 3], 5)\r// => [1, 2, 3]\r\rtakeRight([1, 2, 3], 0)\r// => []" ], "name": "takeRight", "longname": "takeRight", "kind": "function", "scope": "global", "___id": "T000002R000816", "___s": true, "filepath": "takeRight.js" }