MCPcopy Create free account
hub / github.com/lodash/lodash / arraySample

Function arraySample

npm-package/_arraySample.js:10–13  ·  view source on GitHub ↗

* A specialized version of `_.sample` for arrays. * * @private * @param {Array} array The array to sample. * @returns {*} Returns the random element.

(array)

Source from the content-addressed store, hash-verified

8 * @returns {*} Returns the random element.
9 */
10function arraySample(array) {
11 var length = array.length;
12 return length ? array[baseRandom(0, length - 1)] : undefined;
13}
14
15module.exports = arraySample;

Callers

nothing calls this directly

Calls 1

baseRandomFunction · 0.70

Tested by

no test coverage detected