function shuffle(a) { var j, x, i; for (i = a.length; i; i--) { j = Math.floor(Math.random() * i); x = a[i - 1]; a[i - 1] = a[j]; a[j] = x; } return a; } var times = 100000; var res = {}; for (var i = 0; i < times; i++) { var arr = [1, 2, 3]; arr.sort(() => Math.random() - 0.5); var key = JSON.stringify(arr); res[key] ? res[key]++ : res[key] = 1; } // 为了方便展示,转换成百分比 for (var key in res) { res[key] = res[key] / times * 100 + '%' } console.log(res)