sampleSize

Collection
since 4.0.0

Arguments

  • Array|Object The collection to sample.
  • number The number of elements to sample.

Returns

Array the random elements.

Gets n random elements at unique keys from collection up to the size of collection.

Example of Lodash _.sampleSize

_.sampleSize([1, 2, 3], 2);
// => [3, 1]

_.sampleSize([1, 2, 3], 4);
// => [2, 3, 1]