Shuffle an array in-place using Fisher–Yates shuffle
var shuffle = function(a,b,c){for(b=a.length;b;c=0|b*Math.random(),a[c]=[a[--b],a[b]=a[c]][0]);}
var a = [1, 2, 3, 4, 5, 6, 7];
shuffle(a); console.log(a);
// [2, 3, 6, 7, 4, 1, 5]
shuffle(a); console.log(a);
// [3, 6, 5, 2, 1, 4, 7]
My early snippet:
https://gist.github.com/1345090
Updated.