1. //最短代码实现随机打乱数组各个元素的顺序 2. randomSortArr(arr = []) { 3. return [...Array(arr.length)].map( 4. (v, i) => arr.splice(Math.round(Math.random() * (arr.length - 1)), 1)[0] 5. ); 6. },
1. //最短代码实现随机打乱数组各个元素的顺序 2. randomSortArr(arr = []) { 3. return [...Array(arr.length)].map( 4. (v, i) => arr.splice(Math.round(Math.random() * (arr.length - 1)), 1)[0] 5. ); 6. },