var arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g'];
// 随机取得三个元素使得
var newarr = ['e', 'c', 'a'];
巴扎黑2017-04-10 17:54:31
Array.prototype.random = function () {
var idx = Math.floor((Math.random()*this.length));
var n = this.splice(idx,1)[0];
return n;
}
var i = 0;
var a = [];
while(i++<3){
a.push(arr.random())
}
console.log(a);