Skip to content

JavaScript String reversal

Doing string reverse is a common thing in every other programming language.

But here we are going to learn about how efficient and how easy we can do JavaScript String Reversal.

Let’s say to understand this, will take Palindromechallenge where string reversal mainly considered.

Mahamahamis the Palindrome string, even if we reverse it will finally get the output as Palindrome.

const val = 'Mahamaham';
const inputs = val.split('');

const reversedVal = inputs.reverse().join('');

console.log(val === reversedVal); // true

Reverseapi is life saver from ES6JavaScript.

Even you can take a look at our previous blog where listed down the new additions ofES2020JavaScript.

Published inAngularFrameworksGeneralJavaScriptReact