Gets a random element from `array`.
sample([1, 2, 3, 4])
// => 2
| Name | Type | Attribute | Description |
|---|---|---|---|
| array | The array to sample. |
*
{
"comment": "/**\r\n * Gets a random element from `array`.\r\n *\r\n * @since 2.0.0\r\n * @category Array\r\n * @param {Array} array The array to sample.\r\n * @returns {*} Returns the random element.\r\n * @example\r\n *\r\n * sample([1, 2, 3, 4])\r\n * // => 2\r\n */",
"meta": {
"range": [
236,
387
],
"filename": "sample.js",
"lineno": 13,
"path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
"code": {
"id": "astnode100007921",
"name": "sample",
"type": "FunctionDeclaration",
"paramnames": [
"array"
]
},
"vars": {
"length": "sample~length"
}
},
"description": "Gets a random element from `array`.",
"since": "2.0.0",
"tags": [
{
"originalTitle": "category",
"title": "category",
"text": "Array",
"value": "Array"
}
],
"params": [
{
"type": {
"names": [
"Array"
]
},
"description": "The array to sample.",
"name": "array"
}
],
"returns": [
{
"type": {
"names": [
"*"
]
},
"description": "Returns the random element."
}
],
"examples": [
"sample([1, 2, 3, 4])\r// => 2"
],
"name": "sample",
"longname": "sample",
"kind": "function",
"scope": "global",
"___id": "T000002R000728",
"___s": true,
"filepath": "sample.js"
}