Creates a slice of `array` with `n` elements taken from the beginning.
take([1, 2, 3])
// => [1]
take([1, 2, 3], 2)
// => [1, 2]
take([1, 2, 3], 5)
// => [1, 2, 3]
take([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 beginning.\r\n *\r\n * @since 0.1.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 * take([1, 2, 3])\r\n * // => [1]\r\n *\r\n * take([1, 2, 3], 2)\r\n * // => [1, 2]\r\n *\r\n * take([1, 2, 3], 5)\r\n * // => [1, 2, 3]\r\n *\r\n * take([1, 2, 3], 0)\r\n * // => []\r\n */", "meta": { "range": [ 514, 652 ], "filename": "take.js", "lineno": 25, "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo", "code": { "id": "astnode100008956", "name": "take", "type": "FunctionDeclaration", "paramnames": [ "array", "n" ] } }, "description": "Creates a slice of `array` with `n` elements taken from the beginning.", "since": "0.1.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": [ "take([1, 2, 3])\r// => [1]\r\rtake([1, 2, 3], 2)\r// => [1, 2]\r\rtake([1, 2, 3], 5)\r// => [1, 2, 3]\r\rtake([1, 2, 3], 0)\r// => []" ], "name": "take", "longname": "take", "kind": "function", "scope": "global", "___id": "T000002R000814", "___s": true, "filepath": "take.js" }