主题
shuffle
js
_.shuffle(collection)
使用 Fisher-Yates 改组 的版本创建一个混洗值数组。
¥Creates an array of shuffled values, using a version of the Fisher-Yates shuffle.
新增于
¥Since
0.1.0
参数
¥Arguments
collection
(数组|对象):要随机播放的集合。¥
collection
(Array|Object): The collection to shuffle.
返回
¥Returns
(数组):返回新的打乱数组。
¥(Array): Returns the new shuffled array.
示例
¥Example
js
_.shuffle([1, 2, 3, 4]);
// => [4, 1, 3, 2]