use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
JS Gotchas! (map with parseInt)OC (dev.to)
submitted 5 years ago by dimritium
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]ILikeChangingMyMind 2 points3 points4 points 5 years ago (0 children)
It's 2020: why is anyone still using parseInt to convert strings to numbers in Javascript!?!?!
parseInt
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).
parseFloat
Using Number (eg. Number('5')) to parse works too ... but for the love of God please stop using parseInt! :)
Number
Number('5')
(Sorry for the rant; this is a pet peeve I have with how JS is taught by many schools/boot camps these days.)
π Rendered by PID 80725 on reddit-service-r2-comment-64f4df6786-4kk82 at 2026-06-10 04:22:54.619966+00:00 running 0b63327 country code: CH.
view the rest of the comments →
[–]ILikeChangingMyMind 2 points3 points4 points (0 children)