JavaScript: Reverse an Array Elements
Today, lets see different methods of Reversing an Array Elements without using any third party libraries. All the ways of reversing an array is based on Pure JavaScript.
Using Array reverse() method
const a = [1,2,3,4,5,6,7,8,9];
const b = a.reverse();
console.log(b);
Get Amandeep Kochhar’s stories in your inbox
Join Medium for free to get updates from this writer.
Using Array Indexes
const a = [1,2,3,4,5,6,7,8,9];
var b = [];
a.forEach((e,i) => b[a.length-(i+1)] = e);
console.log(b);
Using Array push() & pop() methods
const a = [1,2,3,4,5,6,7,8,9];
const b = [];
while (a.length > 0){
b.push(a.pop())
}
console.log(b);
If you any more Idea to perform this operation. Please mention in the comments. I will try to add mentioned methods. Leave a clap if it helped you in any way.







