Javascript has a reverse() method that you can call in an array

var a = [3,5,7,8];
a.reverse(); // 8 7 5 3

Not sure if that's what you mean by 'libraries you can't use', I'm guessing something to do with practice. If that's the case, you can implement your own version of .reverse()

function reverseArr(input) {
    var ret = new Array;
    for(var i = input.length-1; i >= 0; i--) {
        ret.push(input[i]);
    }
    return ret;
}

var a = [3,5,7,8]
var b = reverseArr(a);

Do note that the built-in .reverse() method operates on the original array, thus you don't need to reassign a.

Answer from Andreas Wong on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ jsref โ€บ jsref_reverse.asp
JavaScript Array reverse() Method
The reverse() method overwrites the original array. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com ยท If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com ยท HTML Tutorial CSS Tutorial JavaScript ...
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ Array โ€บ reverse
Array.prototype.reverse() - JavaScript - MDN Web Docs
In other words, elements order in the array will be turned towards the direction opposite to that previously stated. To reverse the elements in an array without mutating the original array, use toReversed().
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ javascript โ€บ array_reverse.htm
JavaScript - Array reverse() Method
If the array is empty and we try ... nothing as output. <html> <body> <p id="demo"></p> <script> const animals = []; document.getElementById("demo").innerHTML = animals.reverse(); </script> </body> </html>...
๐ŸŒ
W3Schools
w3schools.com โ€บ jsref โ€บ jsref_array_toreversed.asp
JavaScript Array toReversed() Method
The toReversed() method does not overwrites the original array. The toReversed() method is the copying version of the reverse() method. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com ยท If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com ยท HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS Tutorial Bootstrap Tutorial PHP Tutorial Java Tutorial C++ Tutorial jQuery Tutorial
๐ŸŒ
ReqBin
reqbin.com โ€บ code โ€บ javascript โ€บ rgwrzonz โ€บ javascript-reverse-array-example
How do I reverse an array in JavaScript?
let array = ['JavaScript', 'Array', 'Reverse', 'Example']; let newArray = []; for(i = array.length-1; i >= 0; i--) { newArray.push(array[i]); } console.log(newArray); // output: ['Example', 'Reverse', 'Array', 'JavaScript']
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ how-to-reverse-an-array-in-javascript-js-reverse-function
How to Reverse an Array in JavaScript โ€“ JS .reverse() Function
November 29, 2022 - By Dillion Megida In this article, I'll show you two ways to reverse arrays in JavaScript. The reverse method of arrays reverses an array by making the last item the first, and making the first item the last. The other items in between also get rever...
๐ŸŒ
SamanthaMing
samanthaming.com โ€บ tidbits โ€บ 74-how-to-reverse-an-array
How to reverse an array in JavaScript? | SamanthaMing.com
const benjamin = ['๐Ÿ‘ถ', '๐Ÿ‘ฆ', '๐Ÿ‘จ', '๐Ÿ‘ด']; const benjaminButton = benjamin.reverse(); console.log(benjaminButton); // ['๐Ÿ‘ด', '๐Ÿ‘จ', '๐Ÿ‘ฆ', '๐Ÿ‘ถ'] ... One thing to note is that it mutates the original array.
Find elsewhere
๐ŸŒ
Flexiple
flexiple.com โ€บ javascript โ€บ reverse-javascript-array
JavaScript: Reverse an array using different methods - Flexiple
... arr = [1, 2, 3, 4]; arr1 = []; for (let i = arr.length - 1; i >= 0; i--) { arr1.push(arr[i]); } console.log(arr1); //Output: [4, 3, 2, 1] In the above example, we use a decrementing loop to traverse the array arr from backward and store each element to the new array arr1....
๐ŸŒ
W3Schools
w3schools.com โ€บ Jsref โ€บ jsref_typed_reverse.asp
JavaScript Typed Array reverse() Method
The reverse() method overwrites the original array. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com ยท If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com ยท HTML Tutorial CSS Tutorial JavaScript ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ reverse-an-array-in-javascript
Reverse an Array in JavaScript | GeeksforGeeks
January 20, 2025 - Given there are two sorted arrays, we need to merge them into a single sorted array in JavaScript. We will see the code for each approach along with the output. Below are the possible approaches t ... Inversion Count for an array indicates - how far (or close) the array is from being sorted. If the array is already sorted, then the inversion count is 0, but if the array is sorted in the reverse order, the inversion count is the maximum.ร‚ Formally speaking, two elements a[i] and a[j] form an invers
๐ŸŒ
W3Schools
w3schools.com โ€บ js โ€บ tryit.asp
W3Schools online HTML editor
The W3Schools online code editor allows you to edit code and view the result in your browser
๐ŸŒ
Medium
josephcardillo.medium.com โ€บ how-to-reverse-arrays-in-javascript-without-using-reverse-ae995904efbe
How to Reverse Arrays in JavaScript Without Using .reverse() | by Joe Cardillo | Medium
January 31, 2022 - Specifically, take this problem from Eloquent JavaScript, 2nd Edition: Write two functions reverseArray and reverseArrayInPlace. The first, reverseArray, takes an array as an argument and produces a new array that has the same elements in the ...
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ Array โ€บ toReversed
Array.prototype.toReversed() - JavaScript - MDN Web Docs
July 10, 2025 - The toReversed() method transposes the elements of the calling array object in reverse order and returns a new array. When used on sparse arrays, the toReversed() method iterates empty slots as if they have the value undefined. The toReversed() method is generic.
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ javascript-array-reverse-tutorial-with-example-js-code
JavaScript Reverse Array โ€“ Tutorial With Example JS Code
January 18, 2021 - This tutorial will show you five ways to reverse an array in JavaScript with and without the reverse method, along with code snippets that you can use.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ reverse-a-string-in-javascript
Reverse a String in JavaScript - GeeksforGeeks
At each step, we build a new string by adding the current character to the result. ... let name = "GeeksforGeeks"; let reverseString = ''; for (let i = name.length - 1; i >= 0; i--) { reverseString += name[i]; } console.log(reverseString);
Published ย  December 20, 2025
๐ŸŒ
W3Schools Blog
w3schools.blog โ€บ home โ€บ typedarray reverse() javascript
TypedArray reverse() JavaScript - W3schools
June 8, 2019 - The Javascript TypedArray reverse() method reverses an array based on the index. Syntax: array.reverse() Returns: It returns the reversed array. Example 1: Output: SILVER,PLATINUM,GOLD,DIAMOND Example 2: Output: 53,42,21 Please Share
๐ŸŒ
Programiz
programiz.com โ€บ javascript โ€บ library โ€บ array โ€บ reverse
JavaScript Array reverse() (With Examples)
In this tutorial, you will learn about the JavaScript Array reverse() method with the help of examples. The reverse() method returns the array in reverse order.
๐ŸŒ
Javatpoint
javatpoint.com โ€บ javascript-array-reverse-method
JavaScript Array reverse() method
Syntax The method is represented by the following syntax: array.splice(start,delete,element1,element2,?,elementn) Parameter start - It represents... ... JavaScript Array Method The method creates a new array that holds the shallow copy from an array or iterable object.
๐ŸŒ
Flexiple
flexiple.com โ€บ javascript โ€บ how-to-reverse-an-array
How to Reverse an Array In JavaScript โ€“ JS .reverse() Function - Flexiple
June 6, 2024 - Discover how to efficiently reverse arrays in JavaScript using the reverse() method, with simple examples and explanations to enhance your coding skills.