COLLECTED BY
Organization:
Internet Archive
Focused crawls are collections of frequently-updated webcrawl data from narrow (as opposed to broad or wide) web crawls, often focused on a single domain or subdomain.
The Wayback Machine - https://web.archive.org/web/20201220222209/https://github.com/lodash/lodash/blob/master/sample.js
Permalink
18 lines (17 sloc)
396 Bytes
/**
* Gets a random element from `array`.
*
* @since 2.0.0
* @category Array
* @param {Array } array The array to sample.
* @returns {* } Returns the random element.
* @example
*
* sample([1, 2, 3, 4])
* // => 2
*/
function sample ( array ) {
const length = array == null ? 0 : array . length
return length ? array [ Math . floor ( Math . random ( ) * length ) ] : undefined
}
export default sample
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.