shuffle

Shuffles the elements of an array randomly.

shuffle

Shuffles the elements of an array randomly.

Type: transform

Aliases

arrayShuffle, shuffle

Parameters

  • input (array): The input array to shuffle.

Returns

Type: array

The same array with elements randomly shuffled, or empty array if input is not an array.

Examples

shuffle([1, 2, 3]) // [2, 1, 3] (random order)
[1, 2, 3]|shuffle // [3, 1, 2] (random order)
shuffle(["a", "b", "c"]) // ["c", "a", "b"] (random order)
Cookie Notice

We use cookies to enhance your browsing experience.