JavaScript 打乱数组,返回一个数组
const shuffle = array => array.sort(() => 0.5-Math.random());
//output
console.log(shuffle([1,5,2,45]));
console.log(shuffle(['1','2','3','4','5']));
本文来自博客园,作者:重庆熊猫,转载请注明原文链接:https://www.cnblogs.com/cqpanda/p/17059417.html