reverse
The reverse() method returns a copy of an array with the elements in reverse order, while leaving the initial array intact. Tuples retain exact typing thanks to ReverseTuple.
Interactive example
Syntax
typescript
function reverse<
GenericInput extends readonly unknown[]
>(
input: GenericInput
): GenericInput extends AnyTuple ? ReverseTuple<GenericInput> : GenericInputParameters
input: The array whose order you want to reverse.
Return value
A new array containing the same elements but in reverse order. When the input is a tuple, the result exactly reflects the new arrangement of the elements.
