静的に書き出した JS で配列をシャッフルする必要が出たので調べてみました。
こんな感じに書くといけるみたい。
Array.prototype.shuffle = function() {
var i = this.length;
while(i){
var j = Math.floor(Math.random()*i);
var t = this[--i];
this[i] = this[j];
this[j] = t;
}
return this;
}
var a = [1, 2, 3, 4, 5];
a.shuffle();
console.log(a);