Standard built-ins

Array.prototype.toReversed()

Try the free JavaScript compiler

Returns a new ordinary array whose values are read from the receiver in reverse order. Reads ordinary holes as undefined; leaves the receiver unchanged. Nested objects remain shared.

Formal Syntax & Structure

javascript syntaxjavascript
array.toReversed()

Return Value

Array

Reversed copy.

Working Example

Example Snippetjavascript
const a=[1,2,3]; console.log(a.toReversed().join(","),a[0]);
JavaScript Reference