shuffle
shuffle() function
Returns a new array with the elements of the input array shuffled randomly using Fisher-Yates algorithm.
Signature:
declare function shuffle<T extends Iterable<unknown> | AsyncIterable<unknown>>(iterable: T): ReturnArrayType<T>;
Example
shuffle([1, 2, 3, 4, 5]); // [3, 1, 5, 2, 4] (random order)
shuffle("hello"); // ["o", "e", "l", "h", "l"] (random order) Only ASCII codes are shuffled in the case of a string.