Created
December 12, 2015 22:27
-
-
Save endel/3d0e53427b2bc286835c to your computer and use it in GitHub Desktop.
JavaScript one-liner Array shuffle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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