var M = [0,1,2,3,4,5,6,7,8,9];
function shuffleArray(array) {
for (var i = array.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = array[i];
array[i] = array[j];
array[j] = temp;
}
return array;
}
var M = [0,1,2,3,4,5,6,7,8,9];
M = shuffleArray(M);
function shuffle(arr) {
var newArr=[],
count=arr.length
i=null,
rnd=null;
for (i=0; i<count; i++) {
rnd=~~(Math.random() * arr.length);
newArr.push(arr[rnd]);
arr.splice(rnd,1);
}
return newArr;
}
console.log(shuffle(m));