Sorry, I retract my earlier post. The shuffle above is not good, because it takes a long time. The shuffle below completes the task more than 10x faster. It can complete shuffle of a 10,000 item array (I used Math.random to fill each element) in 100 ms, while the shuffle above will take more than 15 seconds. The key here is to switch places, not to copy and recopy the array using splice and push.