您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

_arraySample.js 363B

123456789101112131415
  1. var baseRandom = require('./_baseRandom');
  2. /**
  3. * A specialized version of `_.sample` for arrays.
  4. *
  5. * @private
  6. * @param {Array} array The array to sample.
  7. * @returns {*} Returns the random element.
  8. */
  9. function arraySample(array) {
  10. var length = array.length;
  11. return length ? array[baseRandom(0, length - 1)] : undefined;
  12. }
  13. module.exports = arraySample;