Three Ways to Reverse a String in JavaScript
Sonya Moisset
2.3K28

In ES5, strings are indexable using property notation, and the spec’s algorithms for array reduce methods are intentionally generic, so…


function reverseString(s) {
return [].reduceRight.call(s, function(soFar, curr) {
return soFar + curr;
}, '');
}
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.