DEV Community

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

 
darkmavis1980 profile image
Alessio Michelini

Unfortunately I see it using it for what Number is supposed to do, many, many times.
Btw, if you just need to get the integer (that is a positive number) from a string containing a float, then you should use double tilde operator, which does the same as Math.floor, but just 10 times faster (in Node at least), for example:

console.log(~~'3.2'); // returns 3
console.log(parseInt('3.2')); // returns 3
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
markgoho profile image
Mark Goho

double tilde...🤯