let arr = [1,2,3,4,5,6,7,8,9];
for (let i=0,len=arr.length;i<len;i++) {
let currentRandom = parseInt(Math.random() * (len-1));
let current = arr[i];
arr[i] = arr[currentRandom];
arr[currentRandom] = current;
}
let arr = [1,2,3,4,5,6,7,8,9];
for (let i=0,len=arr.length;i<len;i++) {
let currentRandom = parseInt(Math.random() * (len-1));
let current = arr[i];
arr[i] = arr[currentRandom];
arr[currentRandom] = current;
}
本文标题:打乱数组排序
本文链接:https://www.haomeiwen.com/subject/xsjfbqtx.html
网友评论