# JavaScript Reverse print an array

Here, we will learn how we can **print the array elements in reverse order in JavaScript**?

Submitted by Abhishek Pathak, on October 05, 2017

Arrays are an important data structures in any language. **Reversing an array means printing the array elements in the reverse order**.

**Example:**

var arr = [1,2,3,4,5]; var size = arr.length; for(var i=size-1; i>=0; i--) { console.log(`Element ${i+1} is ${arr[i]}`); }

Output

Element 5 is 5 Element 4 is 4 Element 3 is 3 Element 2 is 2 Element 1 is 1

**Explanation**

In the first line the array is defined. Then with the size variable, we will store the length of the array. After that, we traverse the loop in reverse order, which is starting with **"size-1"** index, which is 4 in our case and we are iterating till the 0th index. Inside the loop, we print or work on our element.

**Easy in JavaScript? Stay tuned for more such tutorials.**

TOP Interview Coding Problems/Challenges

- Run-length encoding (find/print frequency of letters in a string)
- Sort an array of 0's, 1's and 2's in linear time complexity
- Checking Anagrams (check whether two string is anagrams or not)
- Relative sorting algorithm
- Finding subarray with given sum
- Find the level in a binary tree with given sum K
- Check whether a Binary Tree is BST (Binary Search Tree) or not
- 1[0]1 Pattern Count
- Capitalize first and last letter of each word in a line
- Print vertical sum of a binary tree
- Print Boundary Sum of a Binary Tree
- Reverse a single linked list
- Greedy Strategy to solve major algorithm problems
- Job sequencing problem
- Root to leaf Path Sum
- Exit Point in a Matrix
- Find length of loop in a linked list
- Toppers of Class
- Print All Nodes that don't have Sibling
- Transform to Sum Tree
- Shortest Source to Destination Path

Comments and Discussions

**Ad:**
Are you a blogger? Join our Blogging forum.