Node.js examples for Array:Shuffle
Original array but with the order "shuffled"
/**//from w ww. ja v a 2 s. c om * * http://jsfromhell.com/array/shuffle * http://www.brain4.de/programmierecke/js/arrayShuffle.php * * @return {Array} original array but with the order "shuffled" * */ Array.prototype.shuffle = function() { for (var j, x, i=this.length; i; j=parseInt(Math.random() * i), x=this[--i], this[i]=this[j], this[j]=x); };