Javascript Array shuffle( b )

Description

Javascript Array shuffle( b )


Array.prototype.shuffle = function( b )
{
 var i = this.length, j, t;
 while( i )//from w  ww . j a v a  2  s.co  m
 {
  j = Math.floor( ( i-- ) * Math.random() );
  t = b && typeof this[i].shuffle!=='undefined' ? this[i].shuffle() : this[i];
  this[i] = this[j];
  this[j] = t;
 }
 return this;
};



PreviousNext

Related