Shuffles the elements of an array.
The first parameter, array
, is the array to be shuffled. For example, calling shuffle(myArray)
will shuffle the elements of myArray
. By default, the original array won’t be modified. Instead, a copy will be created, shuffled, and returned.
The second parameter, modify
, is optional. If true
is passed, as in shuffle(myArray, true)
, then the array will be shuffled in place without making a copy.
Examples
Syntax
shuffle(array, [bool])
Parameters
array
array to shuffle.
bool
if true
, shuffle the original array in place. Defaults to false
.
Notice any errors or typos? Please let us know. Please feel free to edit src/utilities/array_functions.js and open a pull request!