DEV Community

Discussion on: Reversing a string using .from

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

Is there not an reverse method on the string prototype, there is on the array prototype.

Collapse
 
bugmagnet profile image
Bruce Axtens

As it turns out, no, there is no String.prototype.reverse(). For ages therefore people have been using (usually) var reversedString = "string".split("").reverse().join("") and other approaches.

My 'series' (for want of a better word) came out of Sarah Chima's original posting discussing the issue and offering some options.

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

In that case, nice! Good to measure perf as well nice touch.

Thread Thread
 
bugmagnet profile image
Bruce Axtens

Thank you.