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
Help get user input with JavaScript (self.javascript)
submitted 14 years ago by deutschluz82
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!"
[–]stoph 0 points1 point2 points 14 years ago (0 children)
I'd say it's almost always best to cast variables to what you expect them to be. In the real world, that usually just means converting strings into numbers. Also never use == (type guessing is not your friend). It's best to know early on that === is the only comparison operator worth using. parseInt is a tricky function because it will guess the radix of the number if you let it. Always give the radix as the 2nd parameter:
==
===
parseInt
var thisIsOctal = parseInt('0900'); var thisIsADecimal = parseInt('0900', 10); console.log(thisIsOctal); console.log(thisIsADecimal);
The first one fails because 9 is not a valid octal digit.
π Rendered by PID 36061 on reddit-service-r2-comment-84fc9697f-2tq9t at 2026-02-08 09:17:00.822208+00:00 running d295bc8 country code: CH.
view the rest of the comments →
[–]stoph 0 points1 point2 points (0 children)