Last updated 5 years ago
Was this helpful?
语法:
_.sample(collection)
源代码链接:
npm包链接:
描述:
从collection(集合)中获得一个随机元素。
collection
开始版本:2.0.0
参数:
collection (Array|Object): 要取样的集合。
collection (Array|Object)
返回值:
(*): 返回随机元素。
(*)
例子:
_.sample([1, 2, 3, 4]); // => 2