DEV Community

Discussion on: Performance measurement of JavaScript solutions to common algorithmic questions (part 1)

Collapse
 
lexlohr profile image
Alex Lohr

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.

Collapse
 
detunized profile image
Dmitry Yakimenko

Check out this thread dev.to/alephnaught2tog/comment/925a. The Buffer won everything in the end =)