reverse

reverse

> Functions

Reverses the array array.

Parameters
TypeScript

In JavaScript, a.reverse() reverses the array in place like reverse in LeekScript, but it also returns the array itself: b = a.reverse() therefore makes no copy, b and a are the same array. To get a reversed copy, write a.toReversed() or [...a].reverse().

Python

In Python, a.reverse() reverses the list in place and returns None, like reverse in LeekScript: do not write a = a.reverse(), you would lose the list. To get a new reversed list without touching the original, write a[::-1]; reversed(a) returns an iterator, which you pass to list() to get a list.