We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

Leech on 07/21/06


Tagged

arrays


Versions (?)


Who likes this?

3 people have marked this snippet as a favorite

jkochis
nicolaspar
vali29


Shuffler v1.0


Published in: JavaScript 


URL: http://jsfromhell.com/array/shuffle

Scrambles the elements of an array. Created: 2005.11.03

  1. /**************************************
  2. * Jonas Raoni Soares Silva
  3. * http://www.joninhas.ath.cx
  4. **************************************/
  5.  
  6. shuffle = function(v){ //v1.0
  7. for(var j, x, i = v.length; i; j = parseInt(Math.random() * i), x = v[--i], v[i] = v[j], v[j] = x);
  8. return v;
  9. };

Report this snippet 

You need to login to post a comment.