sampleSize source npm
_.sampleSize(collection, [n=0])
Gets n
random elements from collection
.
Arguments
- collection (Array|Object)
The collection to sample.
- [n=0] (number)
The number of elements to sample.
Returns (Array)
Returns the random elements.
Example
_.sampleSize([1, 2, 3, 4], 2);
// => [3, 1]