It would be best to preallocate the memory, since we know how many characters we are going to need ahead of time. As far as I know there's no way to do that in JavaScript.
Actually, you could convert the string into a typed array and swap back to front and then convert it back. It would probably be more efficient in web assembly.
Grew up in Russia, lived in the States, moved to Germany, sometimes live in Spain. I program since I was 13. I used to program games, maps and now I reverse engineer password managers and other stuff
Location
Berlin and Málaga
Education
MS in CS from State Polytechnic University of St. Petersburg
Actually, you could convert the string into a typed array and swap back to front and then convert it back. It would probably be more efficient in web assembly.
Check out this thread dev.to/alephnaught2tog/comment/925a. The Buffer won everything in the end =)