主题
sample
js
_.sample(collection)
从 collection
获取一个随机元素。
¥Gets a random element from collection
.
新增于
¥Since
2.0.0
参数
¥Arguments
collection
(数组|对象):要采样的集合。¥
collection
(Array|Object): The collection to sample.
返回
¥Returns
(*):返回随机元素。
¥()*: Returns the random element.
示例
¥Example
js
_.sample([1, 2, 3, 4]);
// => 2