数组的随机排序

function rand(a, b) {
   return Math.random()>.5 ? -1 : 1;
}
var arr = [1, 2, 3, 4, 5];
arr.sort(rand);

数组的基础方法, 将有序数组进行随机排序. 主要应用于视频的随机展示

原文地址:https://www.cnblogs.com/xihailong/p/11778519.html