_.sampleSize(collection, [n=1])
Gets n
random elements at unique keys from collection
up to the size of collection
.
Since
4.0.0
Arguments
collection
(Array|Object): The collection to sample.[n=1]
(number): The number of elements to sample.
Returns
(Array): Returns the random elements.
Example
_.sampleSize([1, 2, 3], 2);// => [3, 1]_.sampleSize([1, 2, 3], 4);// => [2, 3, 1]
当前内容版权归 lodash.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 lodash.com .