Returns a copy of the array or the string with its elements shuffled.
Uses Fisher-Yates shuffle with the cryptographically secure random number generator.
shuffled(value)
value
The array or the string to shuffle.
The array can be of any indexable type that has the .slice() method to make a copy.
The string is shuffled using the grapheme clusters as elements.
A copy of the array or the string with its elements shuffled.
random.shuffled([1, 2, 3])
[3, 1, 2]
random.shuffled("Hey 😇")
"yH 😇e"
random.shuffled(new Uint8Array([1, 2, 3]))
Uint8Array [ 2, 3, 1 ]