shuffle es-toolkit
Returns a new array with the elements randomly shuffled.
Usage
shuffle(arr)
Use shuffle when you want to randomly shuffle the elements in an array. It uses the Fisher-Yates algorithm to ensure perfect random shuffling where all permutations appear with equal probability. It's useful for shuffling a deck in card games, randomizing quiz question order, or shuffling a playlist.
You can shuffle various types of arrays.
Parameters
arrreadonly T[]required
The array to shuffle.
Returns
Returns a new array with elements shuffled in random order. The original array is not changed.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.