Skip to content

Instantly share code, notes, and snippets.

@endel
Created December 12, 2015 22:27
Show Gist options
  • Select an option

  • Save endel/3d0e53427b2bc286835c to your computer and use it in GitHub Desktop.

Select an option

Save endel/3d0e53427b2bc286835c to your computer and use it in GitHub Desktop.
JavaScript one-liner Array shuffle
Array.prototype.shuffle = function() {
for(var j, x, i = this.length; i; j = Math.floor(Math.random() * i), x = this[--i], this[i] = this[j], this[j] = x);
return this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment