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.
उदाहरण
सिंटैक्स
shuffle(array, [bool])
पैरामीटर्स
array
Array:
array to shuffle.
bool
Boolean:
if true
, shuffle the original array in place. Defaults to false
.
Returns
Array: shuffled array.
Notice any errors or typos? Please let us know. Please feel free to edit src/utilities/array_functions.js and open a pull request!