Last Updated : 11 Jul, 2025
We have given an input string and the task is to reverse the input string in JavaScript.
Reverse a String in JavaScript Using split(), reverse() and join() MethodsThe 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.
JavaScript
let s = "GeeksforGeeks";
const ans = s.split('').reverse().join('');
console.log(ans);
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.
JavaScript
let s = "GeeksforGeeks";
const ans = [...s].reverse().join("");
console.log(ans);
Writing Your Own Method
Please refer reverse an string tutorial to see different algorithms and implementations of reversing an array.
Javascript program to reverse a string
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4