References

Array.reverse()

Leírás

ABC fordított sorrendben rendezi az elemeket.

Szintaxis

reverse()

Példa

const array1 = ['one', 'two', 'three']
console.log('array1:', array1)
// Expected output: "array1:" Array ["one", "two", "three"]
 
const reversed = array1.reverse()
console.log('reversed:', reversed)
// Expected output: "reversed:" Array ["three", "two", "one"]
 
// Careful: reverse is destructive -- it changes the original array.
console.log('array1:', array1)
// Expected output: "array1:" Array ["three", "two", "one"]
in this article
back to top