Javascript offers a built-in method called reverse
which reverses elements in the original array without creating a new one.
Examples
const numArray = [0, 1, 2, 3, 4];
console.log(numArray.reverse()) //[4, 3, 2, 1, 0]
Published by Muhammad Asfour
Estimated reading time: 1 min
Javascript offers a built-in method called reverse
which reverses elements in the original array without creating a new one.
const numArray = [0, 1, 2, 3, 4];
console.log(numArray.reverse()) //[4, 3, 2, 1, 0]