Creates an array of shuffled values.
Creates an array of shuffled values.
Kind: Exported function
Returns: Array
- Returns the new shuffled array.
Throws:
TypeError
If array is null or undefined.
See: https://en.wikipedia.org/wiki/Fisher-Yates_shuffle
Param | Type | Description |
---|---|---|
array | Array | Object |
The array to shuffle. |
Example
import shuffle from 'shuffle-x';
console.log(shuffle([1, 2, 3, 4])); // e.g. [4, 1, 3, 2]