Access an array in reverse in Javascript
· ☕ 2 min read
Access an array in reverse.
Consider the array in the code block below -
1 const nums = [1, 2, 3]; Accessing the array is easy enough.
1 2 3 4 console.log(nums[0]); console.log(nums[1]); console.log(nums[2]); /* 1 2 3 */ But, what if you want to access the array from the last element?