The arrShuffle() method returns a new array with elements randomly shuffled. Uses the Fisher-Yates shuffle algorithm for uniform randomization.
Identifies the base type of array elements
The array or array-like object to shuffle
A new array with elements in random order
0.14.0
arrShuffle([1, 2, 3, 4, 5]); // e.g., [3, 1, 5, 2, 4]arrShuffle(["a", "b", "c"]); // e.g., ["c", "a", "b"]arrShuffle([1]); // [1]arrShuffle([]); // []// Array-like objectsarrShuffle({ length: 3, 0: "x", 1: "y", 2: "z" }); // e.g., ["z", "x", "y"] Copy
arrShuffle([1, 2, 3, 4, 5]); // e.g., [3, 1, 5, 2, 4]arrShuffle(["a", "b", "c"]); // e.g., ["c", "a", "b"]arrShuffle([1]); // [1]arrShuffle([]); // []// Array-like objectsarrShuffle({ length: 3, 0: "x", 1: "y", 2: "z" }); // e.g., ["z", "x", "y"]
The arrShuffle() method returns a new array with elements randomly shuffled. Uses the Fisher-Yates shuffle algorithm for uniform randomization.