有数组的数组
var a = [[[1, "alpha", "a"],
[2, "beta", "b"]],
[[3, "gama", "c"]],
[[4, "delta", "d"]]];
var b = [];
1) 如何将 a[0]
和 a[2]
合并到 b
中?
2) 如何打乱数组 b
?
这是我正在使用的洗牌算法>>
Array.prototype.shuffle = function() {
for (var i = 0; i < this.length; i++)
this.push(this.splice(Math.random() * (this.length - i), 1)[0]);
return this;
}
使用语法
myArray.shuffle();
最佳答案
关于javascript - 如何合并和打乱数组数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12828707/