reverse

array

Reverses array so that the first element becomes the last, the second element becomes the second to last, and so on.

Signature

reverse<T>(array: T[]): T[]

Parameters

NameTypeDescription
arrayT[]The array to modify

Returns

T[] - Returns array

Examples

Basic usage

import { reverse } from 'dashlite'

const array = [1, 2, 3]
reverse(array)
console.log(array)

Output:

[3, 2, 1]

Notes

  • This method mutates array

Available since version 1.0.0