随机数组值的顺序。
使用Array.sort()可在比较器中使用Math.random()重新排序元素。
Array.sort()
Math.random()
const shuffle = arr => arr.sort(() => Math.random() - 0.5); // shuffle([1,2,3]) -> [2,3,1]
Copyright© 2013-2020
All Rights Reserved 京ICP备2023019179号-8