/*打乱数组顺序*/
var tempArray = [0,1,2,3,4];
tempArray.sort(function(a,b){
/*用Math.random()函数生成0~1之间的随机数与0.5比较,返回-1或1*/
return Math.random()>0.5 ? -1 : 1;
});
JS打乱数组顺序
最新推荐文章于 2023-02-25 13:27:28 发布