var data = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
if (!Array.prototype.shuffle) {
Array.prototype.shuffle = function() {
for(var j, x, i = this.length;
j = parseInt(Math.random() * i),
this[i] = this[j],
this[j] = x);
return this;
};
}
alert(data.shuffle());
js为Array添加打乱元素顺序的函数shuffle()
最新推荐文章于 2023-03-23 11:51:42 发布