DEV Community

Discussion on: You should stop using `parseInt()`

Collapse
 
darkmavis1980 profile image
Alessio Michelini

with the unary operator is still 5/6 times slower than Number

Collapse
 
jonrandy profile image
Jon Randy 🎖️

Interesting - I tested on Firefox and using the unary + was almost twice as fast as Number - jsbench.me/v2kurpao3r/1

Thread Thread
 
jonrandy profile image
Jon Randy 🎖️ • Edited

The same bench on Chrome showed the two methods almost exactly the same speed - sometimes one would be faster than the other, sometimes not

Thread Thread
 
darkmavis1980 profile image
Alessio Michelini

This is interesting, I run the tests using Node (v14.17.6), in "theory" it should give you similar results to Chrome as they both use V8 as the engine, but it's clearly different