Reverse a String in JavaScript
Last Updated :
10 Jan, 2025
Improve
We have given an input string and the task is to reverse the input string in JavaScript.

Using split(), reverse() and join() Methods
The split() method divides the string into an array of characters, reverse() reverses the array, and join() combines the reversed characters into a new string, effectively reversing the original string.
let s = "GeeksforGeeks";
const ans = s.split('').reverse().join('');
console.log(ans);
Output
skeeGrofskeeG
Using Spread Operator
The spread operator(...) is used to spread the characters of the string str into individual elements. The reverse() method is then applied to reverse the order of the elements, and join() is used to combine the reversed elements back into a string.
let s = "GeeksforGeeks";
const ans = [...s].reverse().join("");
console.log(ans);
Output
skeeGrofskeeG
Writing Your Own Method
Please refer reverse an string tutorial to see different algorithms and implementations of reversing an array.