方法一 Fisher–Yates 洗牌算法
function shuffle(arr) { let i = arr.length; while (i) { let j = Math.floor(Math.random() * i--); [arr[j], arr[i]] = [arr[i], arr[j]]; } }
方法二 es6方法
arr.sort(() => 0.5 - Math.random())