DEV Community

Shuvo
Shuvo

Posted on

Faster than parseInt

The fastest way to convert a string to a number is using the + operator
eg. let num = +"5"

Top comments (2)

Collapse
 
joeattardi profile image
Joe Attardi

This is literally the opposite of what's true:

perf comparison

Overall in real world applications, the performance difference is probably negligible unless you have to convert millions of numbers.

Less code does not equal "faster" or "better".

Collapse
 
0shuvo0 profile image
Shuvo

according to MDN
mdn ss