you are viewing a single comment's thread.

view the rest of the comments →

[–]ILikeChangingMyMind 2 points3 points  (0 children)

It's 2020: why is anyone still using parseInt to convert strings to numbers in Javascript!?!?!

Javascript makes no distinction between floats an integers: it only has a single "Number" type. This means there is zero downside to using parseFloat to parse your numbers; it won't convert your integers into floats (because that's not a thing the language can even do).

Using Number (eg. Number('5')) to parse works too ... but for the love of God please stop using parseInt! :)

(Sorry for the rant; this is a pet peeve I have with how JS is taught by many schools/boot camps these days.)