All Downloads are FREE. Search and download functionalities are using the official Maven repository.

node_modules.lodash._arraySample.js Maven / Gradle / Ivy

There is a newer version: 3.3.1
Show newest version
var baseRandom = require('./_baseRandom');

/**
 * A specialized version of `_.sample` for arrays.
 *
 * @private
 * @param {Array} array The array to sample.
 * @returns {*} Returns the random element.
 */
function arraySample(array) {
  var length = array.length;
  return length ? array[baseRandom(0, length - 1)] : undefined;
}

module.exports = arraySample;




© 2015 - 2025 Weber Informatics LLC | Privacy Policy