How to reverse a string in JavaScript

In this tutorial, we are going to see how to reverse a string in Javascript. Strings can be treated as an array or an object in Javascript and we can use this advantage to perform various actions on them.

In this tutorial we will use the following methods:

  • split(): this method will split the string into an array of characters.
  • reverse(): this method reverses all the elements of an array.
  • join(): This method joins all the elements of the array to create a string.


Script to reverse a string in JavaScript:
let s = 'StackHowTo';
let rev = s.split('').reverse().join('');


mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *