重庆熊猫 Loading

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']));
posted @ 2023-01-21 09:02  重庆熊猫  阅读(29)  评论(0编辑  收藏  举报