src code

instance method Array#reverse

Array#reverse([inline = true]) → Array
  • inline (Boolean) – Whether to modify the array in place. Defaults to true. Clones the original array when false.

Reverses the array's contents, optionally cloning it first.

Examples
// Making a copy
var nums = [3, 5, 6, 1, 20];
var rev = nums.reverse(false);
// nums -> [3, 5, 6, 1, 20]
// rev -> [20, 1, 6, 5, 3]
 // Working inline
var nums = [3, 5, 6, 1, 20];
nums.reverse();
// nums -> [20, 1, 6, 5, 3]