js 从数组中随机抽取几个元素
function getRandomArr(arr, count) {//随机抽取 var shuffled = arr.slice(0), i = arr.length, min = i - count, temp, index; while (i-- > min) {//打乱数组 index = Math.floor((i + 1) * Math.random()); temp = shuffled[index]; shuffled[index] = shuffled[i]
原创
2020-06-19 15:02:57 ·
11799 阅读 ·
0 评论