// 使用随机来打乱数组排序的方法 let arr = [1,2,3,4,5,6,7]; arr = arr.sort(function(x, y){ return Math.random() - 0.5; }); alert(arr);