Reverses the given array without mutating it (in contrast to Array.reverse).

Type signature

(xs: any) => any[]

Examples

reverse([1, 2, 3, 4, 5]);
// ⇒ [5, 4, 3, 2, 1]
Try in REPL

Questions

  • How to reverse an array without mutating it?

TypeScript sourceJavaScript source