Hello Friends đź‘‹,

Welcome To Infinitbility! ❤️

When we want to reverse our array, like first element last and last element first then we option to use JavaScript reverse() method.

The JavaScript reverse() method transposes the elements of the calling array object in place, mutating the array, and returning a reference to the array.

Today, we are going to the javascript reverse() method with an example.

Below tutorial and example work on javascript, React, React Native, Vue, Node, Deno, typescript, and all javascript frameworks.


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"]

Thanks for reading…