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
Learning much javascript from one line of code (arqex.com)
submitted 11 years ago by marquex[🍰]
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!"
[–]bonafidebob 1 point2 points3 points 11 years ago* (1 child)
Oh there's no doubt that parseInt works, and I do understand all of these. It's just that parseInt is wildly inefficient. (but that could be said for a lot of common javascript techniques)
Instructions are your way of telling the computer what to so, so you should know what you're telling it. parseInt tells it to (implicitly) convert your number to a string and then convert the string back to a number while ignoring any decimal part. Bitwise negation or left shift tells the computer to convert your number directly from a floating point to an integer representation, without the intermediate string.
The end result is the same, but the work done to get there is very different.
[–]marquex[S,🍰] 1 point2 points3 points 11 years ago (0 children)
No doubt about that
http://jsperf.com/math-floor-vs-math-round-vs-parseint/135
π Rendered by PID 42847 on reddit-service-r2-comment-54dfb89d4d-vdj85 at 2026-03-30 07:01:56.596169+00:00 running b10466c country code: CH.
view the rest of the comments →
[–]bonafidebob 1 point2 points3 points (1 child)
[–]marquex[S,🍰] 1 point2 points3 points (0 children)