在一个数组里随机选出不重复的10项?
var result = []; var arr = [1,2,3,4,5,6,7,8,9,10,11,12,13,14]; var len = arr.length; while(result.length < 10){ var idx = parseInt(Math.random()*1000)%len ; if(arr[idx]){ result.push(arr[idx]); arr[idx] = undefined; } } /* update */ var arr=[1,2,3,4,5,6,7,8,9,10,11,12,13,14]; var myarr=[]; for(va...