js数组随机排序

var ary=[1,2,3,4,5,6,7,8]
    function shuffle(arr) {
        arr.sort(function () {
            return Math.random() - 0.5;
        });
    }
    shuffle(ary)

 

posted @ 2018-10-29 16:36  dongxiaolei  阅读(462)  评论(0编辑  收藏  举报