Example 1 — Official: Shuffle an Array
Permute four numbers into a new order.
_.shuffle([1, 2, 3, 4]);
// → [4, 1, 3, 2] (docs example; your order may differ) How It Works
- Copy. Lodash works on a new array of the values.
- Swap. Fisher–Yates randomly swaps from the end toward the start.
- Result. Every permutation is equally likely.
- Length. Same length as the source — nothing dropped.

