Gets n random elements at unique keys from array up to the size of array.
n
array
The array to sample.
The number of elements to sample.
Optional
Returns the random elements.
5.11.0
sampleSize([1, 2, 3], 2)// => [3, 1]sampleSize([1, 2, 3], 4)// => [2, 3, 1] Copy
sampleSize([1, 2, 3], 2)// => [3, 1]sampleSize([1, 2, 3], 4)// => [2, 3, 1]
Gets
n
random elements at unique keys fromarray
up to the size ofarray
.