JS如何从数组中随机取出若干个数,且不重复

【JS如何从数组中随机取出若干个数,且不重复】//原数组
var arr = [0,1,2,3,4,5,6,7,8,9,10,11]; //输出数组 var out = []; //输出个数 var num = 5; while (out.length < num){ var temp = (Math.random()*arr.length) >> 0; out.push(arr.splice(temp,1)); } alert(out); 转载于:https://www.cnblogs.com/Zeki/p/5902558.html

    推荐阅读