What’s the fastest way to convert String to Number in JavaScript?

There are 4 ways to do it as far as I know.

Number(x);
parseInt(x, 10);
parseFloat(x);
+x;

By this quick test I made, it actually depends on browsers.

https://jsben.ch/NnBKM

Implicit marked the fastest on 3 browsers, but it makes the code hard to read… So choose whatever you feel like it!

Leave a Comment