var m = [1,2,3,4,5,6,7,8,9,0], l = m.length, i = 0, x, j; for(;i<l; i+=1) { j = Math.floor(Math.random()*l)%l; x = m[i]; m[i] = m[j]; m[j] = x; }; alert(m);