The shuffle() method shuffles all the elements of an array.
Example
shuffle() Syntax
The syntax of the array shuffle() method is:
array.shuffle()
Here, array is an object of the Array class.
shuffle() Parameters
The shuffle() method doesn't take any parameters.
shuffle() Return Value
The shuffle() method doesn't return any value. It only shuffles the element of the current array.
Example: Swift Array shuffle()
Output
["Swift", "Java", "C"] [21, 35, 12]
Here, we have used the shuffle() method to shuffle the elements of the languages and priceList arrays respectively.