JavaScript数组随机排序

实现JS中数组随机排序的代码很简单,

var arr = [1,2,3,4,5,6,7,8,9,10];
arr,sort(function(a,b){
        return Math.random()>0/5?a-b:b-a;
})

你可能感兴趣的:(JavaScript数组随机排序)